issue with php/xml...

Can someone give me a hand please.? I’m trying to have php submit a new line in between

I have a html textarea:

<form method="post" action="add.php">
<textarea id="area" size="40" cols=22 rows=12 name="area"></textarea>
<input style="margin-top:10px" type="submit" name="submit" value="submit">
</form>

Here is my PHP code:

[code]

<?php $youTube_ID = $_POST['area']; // This is the data from your field $youTube_ID = strip_tags( $youTube_ID ); // This strips any html from the input as a basic security measure. $xml = <<<XML XML; // ----------------------------------------------------------------- if ( ! $handle = fopen( 'file.xml', 'a' ) ) { die("Unable to open file"); } if( ! fwrite( $handle, $xml ) ) { die("Unable to write to file."); } echo "Successfully wrote to xml."; ?>[/code]

Here is my XML format:
http://pastie.org/3279073

Thanks to anyone who can help.

Timothy

How do I get it to appear inside the and not outside of them?

How do you mean inside the items? Would you not just output it between the tags:

[php]$xml = ‘’ . $youTube_ID . ‘’;[/php]

this is Hey thank for the reply but this is how I did it.

[code]

<?php $dom = new DOMDocument ( '1.0', 'UTF-8' ); $dom->load('items.xml'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $itemstag = $dom->getElementsByTagName ( 'item' )->item ( 0 ); //new item $newitem = $dom->createElement ( "item" ); //type $type = $dom->createAttribute ( 'type' ); $newitem->appendChild ( $type ); $type->appendChild ( $dom->createTextNode ("image" ) ); //src $src = $dom->createAttribute ( 'src' ); $newitem->appendChild ( $src ); $src->appendChild ( $dom->createTextNode ("5.jpg" ) ); //fade $fade = $dom->createAttribute ( 'fade' ); $newitem->appendChild ( $fade ); $fade->appendChild ( $dom->createTextNode ("1" ) ); //delay $delay = $dom->createAttribute ( 'delay' ); $newitem->appendChild ( $delay ); $delay->appendChild ( $dom->createTextNode ("12" ) ); //append new item $itemstag->parentNode->appendChild ( $newitem ); //save xml $dom->save("items.xml"); ?>[/code]

Thanks

Sponsor our Newsletter | Privacy Policy | Terms of Service