views:

26

answers:

1

Hi,

I would like to understand how to access a by its id and not trough array position, example,

I dont want to do this,

$myXML->someNameHere[1]->home[0]

I want to go access someNameHere by its ID "hi"

Thanks a lot for your atention, ;D

A: 

You'll have to use XPath for that.

$nodes = $myXML->xpath('//*[@id="hi"]');

if (!empty($nodes))
{
    $someNameHere = $nodes[0];
}
Josh Davis
Thanks!Can you show one example, on adding a child to it ? Or is simple a mether of doing $someNameHere->addchild(yeah) ?
Jahmaica
Works great! Thanks a lot Josh!
Jahmaica