matthewjbarr
Usenet Archive
- Joined
- Oct 13, 2005
- Messages
- 5
- Reaction score
- 0
Sorry for cross-posting, but I posted this in the PHP group and think it probably should have been here - think maybe I should be looking at XPath expressions to solve the problem. E.g. something like this:
$item->xpath("//movie:image@src")
***
Hi there,
I'm using PHP5's SimpleXML and the simplexml_load_string method to read some XML files.
I can loop round all the elements and extract data from the elements using the usual syntax e.g.
foreach ($xml->list->item as $myitem) { print($myitem->title); }
However, I don't know how to access the value of an attribute where the element has a namespace associated with it, e.g.
<item>
<movie:title>Star Wars</movie:title>
<movie:image src="anImage.jpg" alt="Star Wars" />
</item>
How do I get the value of the src attribute, i.e. "anImage.jpg"?
Thanks!
***
$item->xpath("//movie:image@src")
***
Hi there,
I'm using PHP5's SimpleXML and the simplexml_load_string method to read some XML files.
I can loop round all the elements and extract data from the elements using the usual syntax e.g.
foreach ($xml->list->item as $myitem) { print($myitem->title); }
However, I don't know how to access the value of an attribute where the element has a namespace associated with it, e.g.
<item>
<movie:title>Star Wars</movie:title>
<movie:image src="anImage.jpg" alt="Star Wars" />
</item>
How do I get the value of the src attribute, i.e. "anImage.jpg"?
Thanks!
***