How to retrieve comments from within an XML Document in PHP -


i want extract comments below specific node within xml document, using php. have tried both simplexml , domdocument methods, keep getting blank outputs. there way retrieve comments within document without having resort regex?

simplexml cannot handle comments, dom extension can. here's how can extract comments. have adapt xpath expression target node want.

$doc = new domdocument; $doc->loadxml(     '<doc>         <node><!-- first node --></node>         <node><!-- second node --></node>     </doc>' );  $xpath = new domxpath($doc);  foreach ($xpath->query('//comment()') $comment) {     var_dump($comment->textcontent); } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -