Page 1 of 1

xml replaceChild

Posted: Sat Mar 14, 2009 6:50 am
by lammspillning
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:

Code: Select all

$xdoc = new DomDocument;
$xdoc->Load('myXML.xml');
//
//Update      
//
$saveXML = $xdoc->save('myXML.xml');
return "Updated!";
This is my xml:

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>

Re: xml replaceChild

Posted: Sun Mar 15, 2009 9:49 am
by lammspillning
anyone?