0
我試圖解析XML文件中的PHP看起來像:解析XML與PHP包含名稱空間
<post dsq:id="##Edited out##">
<id />
<message>##Edited out##</message>
<createdAt>2010-07-09T16:08:44Z</createdAt>
<author>
<email>##Edited out##</email>
<name>##Edited out##</name>
<isAnonymous />
</author>
<ipAddress>##Edited out##</ipAddress>
<thread dsq:id="##Edited out##" />
</post>
<post dsq:id="##Edited out##">
<id />
<message>##Edited out##</message>
<createdAt>2010-07-09T16:10:07Z</createdAt>
<author>
<email>##Edited out##</email>
<name>##Edited out##</name>
<isAnonymous />
</author>
<ipAddress>##Edited out##</ipAddress>
<thread dsq:id="##Edited out##" />
</post>
我使用簡單的XML解析它是這樣的:
$xml = simplexml_load_file('disqus.xml');
foreach ($xml->post as $post)
{
echo $post['dsq:id'];
}
然而,我無法從後對象這裏的id屬性:
<post dsq:id="##Edited out##">
任何信息怎麼會被檢索會不勝感激。
命名空間應該位於文檔根目錄下。它是什麼? – Gordon 2011-03-29 21:50:53
<?xml version =「1.0」encoding =「utf-8」?> –
2011-03-29 21:52:58
dsq?也許可以嗎? – Treffynnon 2011-03-29 21:53:06