I'm parsing XML from a data source we use in our web application and I'm having some trouble accessing data from a specific part in the XML.
First, here's the output of a print_r
on what I'm trying to access.
SimpleXMLElement Object
(
[0] =>
This is the value I'm trying to get
)
Then, here's the XML I'm trying to get.
<entry>
<activity:object>
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
<id>542</id>
<title>
Title string is a string
</title>
<content>
This is the value I'm trying to get
</content>
<link rel="alternate" type="html" href="#"/>
<link rel="via" type="text/html" href="#"/>
</activity:object>
</entry>
The content element is what I'm after.
When I access it with $post->xpath('activity:object')[0]->content
I end up with what's above.
I've tried using $zero = 0;
as well as ->content->{'0'}
to access this element, but each time I just get an empty SimpleXML object returned, like below.
SimpleXMLElement Object
(
)
Is there another way to access this that I haven't found yet?
Thanks!