Here is xml file
<stuff>
<foo>
<bar></bar>
<value/>
<pub></pub>
</foo>
<foo>
<bar></bar>
<pub></pub>
</foo>
<foo>
<bar></bar>
<pub></pub>
</foo>
</stuff>
Then i trying to use code
$new=$dom>createTextNode('newnodeName');
$elements = $dom->getElementsByTagName('foo');
foreach($elements as $node){
foreach($node->childNodes as $child) {
$child->parentNode->replaceChild($new, $child);
}
}
- Why this code not replace each $child by $new value
- REturn output in string format not in XML?
- How to change root TagName "stuff" to "team" ?
No comments:
Post a Comment