P
Paul Stuck
hi there
i've got a problem by inserting a new node into a document.
this is the xml file:
<?xml version="1.0"?>
<satz>
<id>1</id>
<data></data>
<info>some info</info>
</satz>
i want to insert a new tag <info> filled with text from user input.
so i tried with this code:
$doc = new DOMDocument();
$doc->load('daten.xml');
$neu = $_POST['neu'];
$satz = $doc->getElementsByTagName( "satz" );
$r = $doc->createElement( "info", $neu );
$doc->appendChild( $r);
$doc->save('filename.xml');
echo $doc->saveXML();
but this codes adds the <info> tag at the end of the document. how can i insert
the element in the right place?
greets
paul
i've got a problem by inserting a new node into a document.
this is the xml file:
<?xml version="1.0"?>
<satz>
<id>1</id>
<data></data>
<info>some info</info>
</satz>
i want to insert a new tag <info> filled with text from user input.
so i tried with this code:
$doc = new DOMDocument();
$doc->load('daten.xml');
$neu = $_POST['neu'];
$satz = $doc->getElementsByTagName( "satz" );
$r = $doc->createElement( "info", $neu );
$doc->appendChild( $r);
$doc->save('filename.xml');
echo $doc->saveXML();
but this codes adds the <info> tag at the end of the document. how can i insert
the element in the right place?
greets
paul