data lost in simplexml_load_string

2019-07-17 09:48发布

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?

2条回答
等我变得足够好
2楼-- · 2019-07-17 10:00
$xml = simplexml_load_string($data);
$namespacesMeta = $xml->getNamespaces(true);
$mediaXML = $xml->children($namespacesMeta['media']);
查看更多
Anthone
3楼-- · 2019-07-17 10:05

You need to look into SimpleXml and Namespaces

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

查看更多
登录 后发表回答