Retrieving single node value from a nodelist

I'm having difficulty extracting a single node value from a nodelist. My code takes an xml file which holds several fields, some containing text, file paths and full image names with extensions. I run an expath query over it, looking for the node item with a certain id. It then stores the matched node item and saves it as $oldnodeNow my problem is trying to extract a value from that $oldnode. I have tried to var_dump($oldnode) and print_r($oldnode) but it returns the following: "object(DOMElement)#8 (0) { } "Im guessing the $oldnode variable is an object, but how do I access it?I am able to echo out the whole node list by using: echo $oldnode->nodeValue;This displays all the nodes in the list.Here is the code which handles the xml file. line 6 is the line in question... \[code\] $xpathexp = "//item[@id=". $updateID ."]"; $xpath = new DOMXpath($xml); $nodelist = $xpath->query($xpathexp); if((is_null($nodelist)) || (! is_numeric($nodelist))) { $oldnode = $nodelist->item(0); echo $oldnode->nodeValue; //$imgUpload = strchr($oldnode->nodeValue, ' '); //$imgUpload = strrchr($imgUpload, '/'); //explode('/',$imgUpload); //$imgUpload = trim($imgUpload); $newItem = new DomDocument; $item_node = $newItem ->createElement('item'); //Create attribute on the node as well $item_node ->setAttribute("id", $updateID); $largeImageText = $newItem->createElement('largeImgText'); $largeImageText->appendChild( $newItem->createCDATASection($largeImgText)); $item_node->appendChild($largeImageText); $urlANode = $newItem->createElement('urlA'); $urlANode->appendChild( $newItem->createCDATASection($urlA)); $item_node->appendChild($urlANode); $largeImg = $newItem->createElement('largeImg'); $largeImg->appendChild( $newItem->createCDATASection($imgUpload)); $item_node->appendChild($largeImg); $thumbnailTextNode = $newItem->createElement('thumbnailText'); $thumbnailTextNode->appendChild( $newItem->createCDATASection($thumbnailText)); $item_node->appendChild($thumbnailTextNode); $urlB = $newItem->createElement('urlB'); $urlB->appendChild( $newItem->createCDATASection($urlA)); $item_node->appendChild($urlB); $thumbnailImg = $newItem->createElement('thumbnailImg'); $thumbnailImg->appendChild( $newItem->createCDATASection(basename($_FILES['thumbnailImg']['name']))); $item_node->appendChild($thumbnailImg); $newItem->appendChild($item_node); $newnode = $xml->importNode($newItem->documentElement, true); // Replace $oldnode->parentNode->replaceChild($newnode, $oldnode); // Display $xml->save($xmlFileData); //header('Location: index.php?a=112&id=5');\[/code\]Any help would be great.Thanks
 
Back
Top