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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -