Jump to content

Adding A New Bit Of Coding To A Xml File?


migroo
 Share

Recommended Posts

Okay I have an xml file that I would like to add on to using php how would I do this?Here is my xml file:

<?xml version='1.0'?><info>  <link>   <icon>New!</icon>   <name>Help me with javascript images!</name>   <auther>Tamuj</auther>   <id>1</id>  </link>  <link>   <icon>New!</icon>   <name>I need to know what is your name?</name>   <auther>Tamuj</auther>   <id>2</id>  </link>  <link>   <icon>Question?</icon>   <name>Do you like the forum?</name>   <auther>Tamuj</auther>   <id>3</id>  </link></info>

I want to add another link block onto the top of the file.How would I go about doing such a thing?The only thing like this I have ever done is delete an entire xml file and replace it with the new code. If any one can help me I would be very happy. :)

Link to comment
Share on other sites

PHP has a DOM API, which is pretty much the same as in JavaScript. You approach any kind of editing the same way you'd do it for JavaScript. Just remember to save the file in the end with the DOMDocument::save() method.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...