Jump to content

XML, SimpleXML + PHP - I might scream!


map200uk

Recommended Posts

Hi,

 

Finally found a way to solve my lyrics issue, however it involved xml (never used xml with php before) so i looked around about dom/xml and simpleXML simpleXML seems nice enough-as what i want to do is in essence incredibly simple

 

but i am still managing to struggle

 

SimpleXMLElement Object ( [@attributes] => Array ( [id] => 120741 [hid] => VxwOBYpM3iY= [exactMatch] => true ) [title] => Comfort Eagle [feat] => SimpleXMLElement Object ( ) [artist] => SimpleXMLElement Object ( [name] => Cake ) )

 

s = simplexml_load_file('test.xml');

 

print_r($s->searchResults->result);

 

 

I am trying to somehow echoe out the hid attribute...but im not sure how what does '@attributes' mean?! I cant seem tro access the array

 

sorry its such a noob question-i have been reading tutorials. but most cover RSS and other xml stuff unrelated to my issue

 

mark

Link to comment
https://forums.phpfreaks.com/topic/49292-xml-simplexml-php-i-might-scream/
Share on other sites

the @attributes is the attributes of the element. Php can access an object as if it was an array and that is what simplexml can do if you use the array operators on simplexml objects you will access the attribs it can also be used for selecting children in certain instances. 

 

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.