xml replaceChild
Posted: Sat Mar 14, 2009 6:50 am
I'm trying to update a xml file of mine with php. I fugured out how to delete and add new elements, but I cant figure out how to update existing elements. I'v been using DOM for deleting and adding, but I can't get a hold of how to work with DOM replacechild.
So this Is all I have now for my update code:
This is my xml:
So this Is all I have now for my update code:
Code: Select all
$xdoc = new DomDocument;
$xdoc->Load('myXML.xml');
//
//Update
//
$saveXML = $xdoc->save('myXML.xml');
return "Updated!";Code: Select all
- <videos>
- <item>
<question>What year is it?</question>
<answers>2009/1985/2035/1745</answers>
<url>312656</url>
<position>2</position>
</item>
- <item>
<question>What's your name?</question>
<answers>John/Lisa/Tomas/Sean</answers>
<url>321546</url>
<position>2</position>
</item>
</videos>