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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...