blinks58 Posted May 26, 2014 Share Posted May 26, 2014 I'm trying to delete the <identifier> node of some XML, using the following code; unsuccessfully. Can someone help me identify where I'm going wrong? TIA $newXML = ""; $xmlString = Fedora_API::callGetDatastreamContents($this->pid, 'MODS', true); $doc = DOMDocument::loadXML($xmlString); $xpath = new DOMXPath($doc); $fieldNodeList = $xpath->query("/identifier"); foreach ($fieldNodeList as $node) { $fieldNodeList->removeChild($node); } $newXML = $doc->SaveXML(); Link to comment https://forums.phpfreaks.com/topic/288771-deleting-an-xml-node/ Share on other sites More sharing options...
blinks58 Posted May 27, 2014 Author Share Posted May 27, 2014 Solved: $newXML = ""; $xmlString = Fedora_API::callGetDatastreamContents($this->pid, 'MODS', true); $doc = DOMDocument::loadXML($xmlString); $xpath = new DOMXPath($doc); $fieldNodeList = $xpath->query("/identifier"); foreach($fieldNodeList as $node){ $node->parentNode->removeChild($node); } $newXML = $doc->SaveXML(); / Link to comment https://forums.phpfreaks.com/topic/288771-deleting-an-xml-node/#findComment-1480979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.