How can I remove the text of a node without removing child nodes?

6mastermeb

New Member
I'm working on creating XML docs from values in a database. Initially, the program exports this XML:\[code\]<customDataElementlanguage>English</customDataElementlanguage>\[/code\]I've created this PHP to change the XML tree:\[code\] if ($Element->nodeValue = "http://stackoverflow.com/questions/3938149/EN") { $Element->nodeValue = "http://stackoverflow.com/questions/3938149/English"; } $doc2 = $Element->ownerDocument; $titleElement = $doc2->createElement('title','language'); $valueElement = $doc2->createElement('value',$Element->nodeValue); $Element->appendChild($titleElement); $Element->appendChild($valueElement); //$Element->nodeValue="";\[/code\]into this:\[code\]<customDataElementlanguage>English<title>language</title><value>English</value></customDataElementlanguage>\[/code\]My problem is that I can't seem to find a way to remove the "English" text from the node without wiping out the child nodes \[code\]title\[/code\] and \[code\]value\[/code\] inside. That's what happens when I end my PHP code with \[code\]$Element->nodeValue="";\[/code\]I'd also like to change the name of the customDataElemementlanguage node to customDataElement but I can work on that later I suppose :)
 
Back
Top