Jump to content

simplexml question


saipkjai

Recommended Posts

hi

 

  right now I have the following feed

 

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

<entry>
   <title>Test entry #3</title>
   <id>http://example.org/article3</id>
   <updated>2006-10-03T13:14:34Z</updated>
   <link href="http://example.org/article3" />
   <content type="xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml">

     <xhtml:div>This is also <xhtml:em>very</xhtml:em> exciting. & </xhtml:div>
   </content>
</entry>

<entry>
   <title>Test entry #4</title>

   <id>http://example.org/article4</id>
   <updated>2006-10-03T14:14:34Z</updated>
   <link href="http://example.org/article4" />
   <content type="xhtml">
     <div xmlns="http://www.w3.org/1999/xhtml"><p>This is also <em>very</em> exciting.</p>
     <p>Yes, it is.</p></div>

   </content>
</entry>

</feed>

 

when I try to parse it using simplexml like the following, only part of the entry 3 element appears, and there is nothing for the entry 4. Am I in the wrong track? how should I fix this problem?

 

foreach ($xml->entry as $entry)
{
		foreach ($entry->content->children("http://www.w3.org/1999/xhtml") as $child){

			echo "$child";

		}

}

 

thx for the help

Link to comment
https://forums.phpfreaks.com/topic/72809-simplexml-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.