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(); Quote Link to comment Share on other sites More sharing options...
Solution blinks58 Posted May 27, 2014 Author Solution 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(); / Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.