blinks Posted July 31, 2012 Share Posted July 31, 2012 I have a series of xml files, which contain the line: <para type="series"> which I want to change to <para type="test"> I'm using the following code for an individual file, but the change is not happening. Any advice appreciated. $doc = DOMDocument::loadXML($xmlString); $xpath = new DOMXPath($doc); $fieldNodeList = $xpath->query("/para"); $fieldNodeList->setAttribute('type', 'test'); $newXML = $doc->SaveXML(); Link to comment https://forums.phpfreaks.com/topic/266478-changing-an-attribute/ Share on other sites More sharing options...
blinks Posted July 31, 2012 Author Share Posted July 31, 2012 Did it; set second $fieldNodeList to $fieldNodeList->item(0)->setAttribute('type', 'test'); :-) Link to comment https://forums.phpfreaks.com/topic/266478-changing-an-attribute/#findComment-1365577 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.