Saturday, 31 August 2013

How input in a string a XML content:encode

How input in a string a XML content:encode

I have this XML
<rss>
<channel>
<item>
<title>
Title content
</title>
<link>
http://www2.XXXXXX
</link>
<dc:creator>YYYYY</dc:creator>
<category>FFFFF</category>
<description>
<![CDATA[<P>O XXXXX (...)]]>
</description>
<content:encoded>
<![CDATA[<P>O XXXXXXX XXXXXXXXXX XXXXX XXXXX XXXXX XXXXXXXXXX XXXXX
XXXXX</P>]]>
</content:encoded>
</item>
....
I use this code to read this XML, and I want get the content value from XML
$rawFeed = (file_get_contents($url_feed));
$xmldoc = new SimpleXmlElement($rawFeed);
foreach ($xmldoc->channel->item as $xmlinfo){
$title = $xmlinfo->title);
$content = $xmlinfo->content);
}
The problem is: I can recover the string $title = 'Title content', but I
cant return in a string $content
PS: I try use content:encoded, but doesn't work too
PS2. when I print_r($xmlinfo), I get
SimpleXMLElement Object ( [title] => TITLE XXXXXX [link] =>
http://www2.XXXXX.php? [category] => YYY [description] =>
SimpleXMLElement Object ( ) )

No comments:

Post a Comment