Jump to content

Save XML file from textarea, validation problem?


Packy

Recommended Posts

Hello hello,

 

I have loaded XML file into textarea, after editing, how to save it?

 

Going with:

$sample = $HTTP_POST_VARS['XML_file_textarea'];

$sample = $dom->saveXML();

$dom->save('XML/sample.xml');

 

does not work because I lose ane XML tag, I only have saved information between tags.

 

Is this some validation issue where PHP delibarately strip tags or something else?

 

Please help.

 

Thanks...

 

Here is complete code of page:

 

<?php

$dom = new DOMDocument;

$dom->load('XML/sample.xml');

$dom->formatOutput = true;

$sample = $dom->saveXML();

?>

 

<table border=1>

<form name="XML_textarea" action="<?=$_SERVER['PHP_SELF']?>" method="post">

<tr>

<td><textarea rows="30" cols="100" name="XML_file_textarea"><?php print $sample; ?></textarea></td>

</tr>

<tr>

<td align="right"><input type="submit" name="submit" value="Submit"></td>

</tr>

</form>

</table>

 

<?php

if ($HTTP_POST_VARS["submit"]=="Submit"){

$sample = $HTTP_POST_VARS['XML_file_textarea'];

 

echo $sample . "<br><br><br>";

 

$sample = $dom->saveXML();

$dom->save('XML/sample.xml');

echo '<br>Changes saved.<br>';

} //if HTTP_POST_VARS

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.