php - SimpleXML access separated text nodes -


i have xml file following:

... <myelement>introduction:<br />    ... </myelement> ... 

are there way return "introduction:" , rest after </br> of element?

i using php , simplexml. naively use echo $document->myelement shows "introduction:...", mixed introduction line , content.

simplexml not have concept of text-nodes might know domdocument (see this comparison table).

so in php option import <myelement> element dom , operation there:

 # prints "introduction:"   echo dom_import_simplexml($myelement)->firstchild->data;  //                                          ^        //                                          `- domtext 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -