Jump to content

Changing an attribute


blinks

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.