Jump to content

How is this (super simple) XML document parsed?


br3nn4n

Recommended Posts

Hey guys,

 

I have an XML doc that needs parsing:

 

 
<ISBNdb server_time="2009-08-11T22:49:51Z"> 
<AuthorList total_results="17" page_size="10" page_number="1" shown_results="10"> 
<AuthorData person_id="rowling_jk"> 
<Name>Rowling JK</Name> 
</AuthorData> 
<AuthorData person_id="rowling_j_k_a01"> 
<Name>Rowling J K</Name> 
</AuthorData> 
<AuthorData person_id="cathy_rowling"> 
<Name>Cathy Rowling</Name> 
</AuthorData> 
<AuthorData person_id="jessica_rowling"> 
<Name>Jessica Rowling</Name> 
</AuthorData> 
<AuthorData person_id="jk_rowling"> 
<Name>JK Rowling</Name> 
</AuthorData> 
<AuthorData person_id="joanne_k_rowling"> 
<Name>Joanne K. Rowling</Name> 
</AuthorData> 
<AuthorData person_id="marije_rowling"> 
<Name>Marije Rowling</Name> 
</AuthorData> 
<AuthorData person_id="marjie_rowling"> 
<Name>Marjie Rowling</Name> 
</AuthorData> 
<AuthorData person_id="mary_c_rowling"> 
<Name>Mary C. Rowling</Name> 
</AuthorData> 
<AuthorData person_id="marye_rowling"> 
<Name>Marye Rowling</Name> 
</AuthorData> 
</AuthorList> 
</ISBNdb> 

 

I need the person_id value of the AuthorData element really, and maybe the name element's content too. I'm using PHP 5 so SimpleXML is available.

 

For the name element I'm thinking of doing a foreach:

 

foreach($xml->name as $name) {
echo $name;
}

 

But to get the person_id attribute...I'm clueless. How do I access that?

 

Thanks!!

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.