Jump to content

editing xml using php

Recommended Posts

Is it possible to use a php form to edit xml? I was thinking something like this.

<html><head><title>xml editor</title></head><body><form method="post"><input type="text" name="xml_code" /><input type="submit" value="change xml file" /></form><?php$fp = fopen("edited.xml", "w");fwrite($fp, $_POST['xml_code']);?></body></html>

Link to post
Share on other sites

very very close, but wrong;you might want to do it like this:

<form action="otherPage.php" method="post"><textarea name="text"></textarea><br/><input type="submit" value="submit" name="submit"/></form>

otherPage.php is as followed:

<?phpif(isset($_POST['text'])){ $file = file_get_contents("edited.xml") or die("could not open edited.xml"); $file .= $_POST['text']; file_put_contents("edited.xml",$file) or die("Could not write to file");}else{ echo "you have come here not of how you are suppposed to... go the ###### away";]?>

Link to post
Share on other sites

Join the conversation

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

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...