xml replaceChild

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lammspillning
Forum Newbie
Posts: 14
Joined: Fri Aug 17, 2007 10:50 am

xml replaceChild

Post 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>
lammspillning
Forum Newbie
Posts: 14
Joined: Fri Aug 17, 2007 10:50 am

Re: xml replaceChild

Post by lammspillning »

anyone?
Post Reply