Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

xml parsing

12:29 pm on Apr 12, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 26, 2005
votes: 0

Hello all, I need to parse some xml documents. I use Simple:XML and it works ok up to the point of matching elements that occur just once in my documents. How can I process something like:

<AuthorList CompleteYN="Y">
<Author ValidYN="Y">
<Author ValidYN="Y">
<Author ValidYN="Y">

and print all Authors' names?

4:36 am on Apr 13, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 12, 2005
votes: 0

It would be something like this, which you have to include in a loop:

foreach($xml->Author as $author)
echo $author->LastName.'<br/>';
6:52 pm on Apr 13, 2008 (gmt 0)


WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
votes: 0


What's this? You should be getting an error in your tag mismatches.

After you fix that (remove it) you will have to go another node deeper in your xml object to get the Author information:

foreach($xml->AuthorList->Author as $author) { 
echo $author->LastName.'<br/>';

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members