xml parsing - php access sub elemement in XML -


i using simplexml in php parse xml document. have following element not able create proper path 1 of sub elements. here element:

<wp:category> <wp:term_id>13</wp:term_id> <wp:category_nicename>cleaner</wp:category_nicename> <wp:category_parent></wp:category_parent> <wp:cat_name><![cdata[cleaner]]></wp:cat_name> 

the element need access <wp:cat_name>.

what path use access data?

lee


$wp->category->cat_name; path element.

i think can import xml domdocument without preserving namespaces

$xml =' <wp:category>     <wp:term_id>13</wp:term_id>     <wp:category_nicename>cleaner</wp:category_nicename>     <wp:category_parent></wp:category_parent>     <wp:cat_name ><![cdata[cleaner]]></wp:cat_name> </wp:category>';  $data = new domdocument; $data->preservewhitespace = false; $data->loadxml($xml, libxml_noerror); foreach($data->documentelement->childnodes $child) {     if($child->nodename == 'cat_name')     {         print_r($child->nodevalue);     } } 

this output

cleaner 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -