ThatOneGuy
New Member
I'm trying to figure out how to rename a node in XML using PHP?I Have come this far:\[code\]$dom = new DOMDocument( '1.0' );$dom->preserveWhiteSpace = false;$dom->formatOutput = true;// load the xml file$dom->loadXML( '<?xml version="1.0" encoding="ISO-8859-1"?><library> <data> <invite> <username>jmansa</username> <userid>1</userid> </invite> <update>1</update> </data></library>', LIBXML_NOBLANKS );$xpath = new DOMXPath($dom);//find all 'data' nodes.$node = $xpath->query("//data");// if foundif( $node->length ) { foreach ($node as $n) { // RENAME HERE? // }}echo "<xmp>". $dom->saveXML() ."</xmp>";\[/code\]Now, I want to rename \[code\]<data>\[/code\] to \[code\]<invites>\[/code\]. Can this be done and if yes, how?