Page 1 of 1

XML insertion

Posted: Wed Nov 22, 2006 4:45 am
by tvks
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,

I have many XML files with the following structure.

[syntax="xml"]
<employees>

  <employee>
     <name>Rajiv</name>
     <telephone>1234</telephone>
  </employee>

  <employee>
     <name>Waltai</name>
     <telephone>2113</telephone>
  </employee>

</employees>
I need to develop a function in php where I pass the following parameters:

filename (XML file name abc.xml)
rajiv (record to be changed <name>)
mail (field name to be inserted <mail>)
rajiv@plus2net.com (value to be inserted)

Say, I am naming the function as[/syntax]

Code: Select all

insert("abc.xml","rajiv","mail","rajiv@plus2net.com")
When I execute this function the details of employee rajiv in above xml file should change as

Code: Select all

  <employee>
     <name>Rajiv</name>
     <telephone>1234</telephone>
     <mail>rajiv@plus2net.com</mail>
  </employee>
Kindly help me urgently.

With regards


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Nov 22, 2006 6:12 am
by feyd
Do you have one of the XML libraries installed into PHP? What have you tried so far?