Accessing a SimpleXMLElement object
Posted: Sat Dec 19, 2009 9:09 am
I have the following SimpleXMLElement:
In $xml. How can I access ip directly? I can only get it wrapped in the SingleXMLElement object. If I try $xml->connections->connection[1]->ip, I get
And if I access $xml->connections->connection[1]->ip[0], I still get
What's wrong here? My XML looks like this:
Thanks
Code: Select all
SimpleXMLElement Object
(
[connection] => Array
(
[0] => SimpleXMLElement Object
(
[ip] => 200.12.186.6
[port] => 1234
)
[1] => SimpleXMLElement Object
(
[ip] => 200.12.186.7
[port] => 1236
)
)
)Code: Select all
SimpleXMLElement Object
(
[0] => 200.12.186.7
)Code: Select all
SimpleXMLElement Object
(
[0] => 200.12.186.7
)
Code: Select all
<?xml version='1.0' standalone='yes'?>
<stuff>
<connections>
<connection><ip>200.12.186.6</ip><port>1234</port></connection>
<connection><ip>200.12.186.7</ip><port>1236</port></connection>
</connections>
</stuff>