Page 1 of 1

xml dom and php

Posted: Fri Mar 12, 2010 3:29 pm
by lui10e6
Hi,
I want to append one xml tag to an existing xml file. That's it.
I want to use XML DOM to acomplish this but i am not sure if this is that simple.
I need to load the xml file, place one new tag at the beggining and then save(xml_file) without the need to read each tag and write it out. I am not much familour with xml dom, but i coudn't find an example like this.
Can I do that?

thanks.

Re: xml dom and php

Posted: Fri Mar 12, 2010 3:33 pm
by VladSun

Re: xml dom and php

Posted: Fri Mar 12, 2010 5:53 pm
by lui10e6
thanks, I already looked into that, tried something with
DOMDocumentFragment::appendXML — Append raw XML data
and i have the new tag at the end of the xml file. At least is something. Now I am trying to move it to be the first tag, not the last.

Re: xml dom and php

Posted: Sat Mar 13, 2010 4:41 am
by VladSun
Probably, you will need to use DOMDocument::createElement and DOMNode, DOMXPath functions.

Re: xml dom and php

Posted: Sat Mar 13, 2010 9:03 am
by lui10e6
VladSun wrote:Probably, you will need to use DOMDocument::createElement and DOMNode, DOMXPath functions.
thanks for pointing that out, it helped. I did what I wanted, put a new tag at the begging of a big xml file.
thank you.