I am looking to insert data from a PHP form in to an XML document and print it in the browser. Can someone point me in the right direction?
Something similar to:
Form:
<form name="createDoc" action="createDocument.php" method="post">
<input name="name" type="text" id="name">
</form>
XML:
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<article id="0001">
<title>My book</title>
<para>Lorem ipsum dolor sit amet, **[name here]** consectetur adipiscing elit. Phasellus consequat purus ac tellus imperdiet ullamcorper.</para>
</article>
</doc>
Result:
Lorem ipsum dolor sit amet, Joh Doe consectetur adipiscing elit. Phasellus consequat purus ac tellus imperdiet ullamcorper.
Thanks in advance :)
The fastest way is to put the XML into a string, and use
str_replace("**[name here]**",$_POST[name],$xmlstr);
In the future, you may want to post what you've already tried. We are here to help you figure out a problem, not solve it for you.