View Full Version : XML Child Tag rename

03-23-2009, 01:01 PM

i have done many different way to rename Child TAG to allow

here is example

<author> dunno</author>

i know it sound wrong code but i have different many way

$dita = new DOMDocument;

seems code is not working and i have try another way but fail

my aim is change on outputclass XML like

<?xml version="1.0"?>
<child outputclass="internal" >bar</child>
<price outputclass="internal >20</price>
<author outputclass= "external"> dunno</author>

that i want to set the outputclass attribute to outputclass="external" or "internal"

or prefer use

PHP (or XML) code call the "control file (can be an ASCII text file or an XML file)" , and then the PHP code does the processing logic on the desired DITA files based on the info in the control file.

03-23-2009, 01:56 PM
You're usage of replacechild is incorrect. ReplaceChild requires two parameters, the new and the old nodes.
However, I don't see where you're actually needing to do this. The difference between the two blocks of xml code only indicate changes in attributes. You can fetch a domNodeList from the getElementsByTagName method (it won't work on book though, since you don't have a book element), iterate through the list or fetch a single item (I assume that $id is for this purpose, but I don't see it defined anywhere), and use the createAttribute method on DomDocument, and append this to the desired DOMNode(s).