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
You'll have to use XPath for that.
$nodes = $myXML->xpath('//*[@id="hi"]');
if (!empty($nodes))
{
$someNameHere = $nodes[0];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.