I have a large XML file that I want to parse and put into a database. For example, this file:
<aa>
<bb>Some text goes here and <br /> some more on a new line
there are other <junk/> tags that I want to keep ignoring
</bb>
</aa>
My code below uses SimpleXML to parse the text content inside the bb tag, but it silently ignores the <br /> tag. How can I modify my code to accept <br/> but not <junk/>?
$xml = simplexml_load_file("ab.xml");
foreach( $xml->bb as $bb ) {
// $bb now contains the text content of the element, but no tags
}
No comments:
Post a Comment