php - XML element holds non xml elements (not wrapped in cdata) -
i using simple xml php , trying parse <content> element part of following tree:
<entry>
...<title>
...<link>
...<summary>
...<content>
the problem <content> element cannot read string because has "non string" content not wrapped in cdata:
<content type="xhtml" xml:lang="en-us" xml:base="..."> <div xmlns="http://www.w3.org/1999/xhtml"><p><strong>text... text...</strong> text <a href="..." target="_self">link</a>. text</p> </content> i use following code:
$xml = simplexml_load_file($feed_uri); and then:
foreach($xml->entry $entry){ $item = new rssitem(); $item->title = (string) $entry->title; $item->content = (string)$entry->content; $item->date = (string) $entry->published; my content member var empty. others expected if change $item->content = (string)$entry->content; $item->content = $entry->content; object nested in $item->content variable
any ide how force parser not interpret elements found in content element (div, p etc.) nested elements?
thanks in advance, l
try $entry->content->asxml().
Comments
Post a Comment