示例#1
0
        }
        // get our attributes if we have any
        $arAttributes = array();
        if ($oDomNode->hasAttributes()) {
            foreach ($oDomNode->attributes as $sAttrName => $oAttrNode) {
                // retain namespace prefixes
                $arAttributes["@{$oAttrNode->nodeName}"] = $oAttrNode->nodeValue;
            }
        }
        // check for namespace attribute - Namespaces will not show up in the attributes list
        if ($oDomNode instanceof DOMElement && $oDomNode->getAttribute('xmlns')) {
            $arAttributes["@xmlns"] = $oDomNode->getAttribute('xmlns');
        }
        if (count($arAttributes)) {
            if (!is_array($mResult)) {
                $mResult = trim($mResult) ? array($mResult) : array();
            }
            $mResult = array_merge($mResult, $arAttributes);
        }
        $arResult = array($oDomNode->nodeName => $mResult);
        return $arResult;
    }
}
$dom = new XmlToArray();
$dom->load('html.xml');
$html = $dom->readFile();
$html = $html['NotepadPlus']['AutoComplete']['KeyWord'];
$dom->load('javascript.xml');
$js = $dom->readFile();
$js = $js['NotepadPlus']['AutoComplete']['KeyWord'];
$nArray = array_merge($html, $js);