问题
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