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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.