data lost in simplexml_load_string

[亡魂溺海] 提交于 2019-12-13 15:27:40

问题


I am reading xml with this code.

$xml = simplexml_load_string($data);

it reads correctly, and can access to data via $xml->title etc. but i need to access to CDATA and <media:xxx> tags.

example of xml: pastie from: http://www.metacafe.com/api/item/4779040/

is possible to parse that data? how?


回答1:


$xml = simplexml_load_string($data);
$namespacesMeta = $xml->getNamespaces(true);
$mediaXML = $xml->children($namespacesMeta['media']);



回答2:


You need to look into SimpleXml and Namespaces

Try this - http://blog.sherifmansour.com/?p=302



来源:https://stackoverflow.com/questions/3637858/data-lost-in-simplexml-load-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!