|
Posted by fragmonster on 03/01/06 10:43
Hi,
I need to manipulate XML files with PHP. So i need to extract and
insert nodes in my files.
For the extraction : no problem with XPath, it works fine.
But, for inserting new nodes, it's more complicated. It's works but I'm
experiencing some XML code formating problems
Lets take an example of XML source file, in which I have to insert data
:
<A>
<Objects>
<Obj>foo</Obj>
<Obj>bar</Obj>
</Objects>
</A>
In this file I must insert a new group of tags (DTD complient tags) in
order to obtain this output file
<A>
<New>
<Data1></Data1>
<Data1></Data1>
</New>
<Objects>
<Obj>foo</Obj>
<Obj>bar</Obj>
</Objects>
</A>
But, instead I obtain this output :
<A>
<Objects>
<Obj>foo</Obj>
<Obj>bar</Obj>
</Objects>
<New><Data1></Data1><Data1></Data1></New></A>
My new group of tags has been inserted at the and of my file, and my
XML code is not correctly indented.
What can I do to fix this?
Thanks
Navigation:
[Reply to this message]
|