Appending XML php5 possible tutorial?
Posted: Mon Jan 29, 2007 1:06 pm
Hello,
curious if anyone knows a good place to learn how to append my $dom object to
an already exisiting file:
psuedo code:
So original xml file would start out like:
and end up after adding the new $dom info
I can add to my root as a new root element but I want to add my $dom into my <people> element.
Is there a tutorial on how to do this. I can't find one out there (yet). I'd like to read that before posting questions (besides this one).
thanks,
sky
curious if anyone knows a good place to learn how to append my $dom object to
an already exisiting file:
psuedo code:
Code: Select all
<?php
$dom = new DomDocument;
$dom->load('myXML.xml');
##### Can Do This ###########
// create my xml elements and nodes
// append new element and nodes to $dom
#########################
#### HARD PART ########
// add new $dom to xml without overwriting old xml elements
####################
$dom->save('myXML.xml')
// save over original file.
?>Code: Select all
<?xml .....
<people>
<person>
<name> Tom</name>
</person>
</people>Code: Select all
<?xml .....
<people>
<person>
<name> Tom</name>
</person>
<person>
<name> Jane </name>
</person>
</people>I can add to my root as a new root element but I want to add my $dom into my <people> element.
Is there a tutorial on how to do this. I can't find one out there (yet). I'd like to read that before posting questions (besides this one).
thanks,
sky