Getting Information out of a node
dominfo.php:
<?php

$dom 
= new DomDocument();
$dom->load("examples/books.xml");

$xp = new Domxpath($dom);
//get the first Book
nodeInfo$xp->query("//book[1]")->item(0));

//dc:subject of first Book
nodeInfo($xp->query("//book[1]/dc:subject")->item(0));

//textnode of dc:subject
nodeInfo($xp->query("//book[1]/dc:subject")->item(0)->firstChild);

function 
nodeInfo($node) {
    print 
"*****\n";
    print 
"--- nodeType ---\n";
    print 
$node->nodeType"\n";
    print 
"--- nodeName ---\n";
    print 
$node->nodeName "\n";
    print 
"--- localName --- \n";
    print 
$node->localName ."\n";
    print 
"--- namespaceURI --- \n";
    print 
$node->namespaceURI ."\n";
    print 
"--- prefix --- \n";
    print 
$node->prefix ."\n";
    print 
"--- nodeValue ---\n";
    print 
$node->nodeValue ."\n\n";
}

 
Getting Information out of a node © copyright 2004  Bitflux GmbH