我正在尝试使用PHP和Simple_XML读取XML文件(30k行)但没有成功:
$source = "./xml/test_1.XML";
$sitemap = simplexml_load_file($source);
foreach($sitemap->children() as $child)
{
echo $child->getName().":\n";
foreach($child->children() as $subchild) {
echo "--->".$subchild->getName().": ".$subchild."\n";
}
}
XML文件(文件的一小部分):
<?xml version="1.0" encoding="GB2312"?>
<spec:BACKUPCFG xmlns:spec="http://www.xxxx.com/specs/">
<spec:fileHeader fileFormatVersion="1.1.0" NRMversion="DATAV100" NEversion="V100" synType="synall"/>
<spec:synData>
<class synlabel="448">
<TBLANGNO id="0">
<attributes>
<LangNo>0</LangNo>
</attributes>
</TBLANGNO>
</class>
</spec:synData>
<spec:fileFooter label="475" ExportResult="Success" dateTime="2014-07-30T19:05:13-03:00">
<spec:moclistincluded>TBLANGNO</spec:moclistincluded>
</spec:fileFooter>
</spec:BACKUPCFG>
我的代码输出是一个空字符串。如果我做了print_r($ sitemap),我得到了:
SimpleXMLElement Object
(
)
事实上我想读这样的东西:
TBLANGNO - id = 0 / LangNo = 0
提前致谢。