PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php if (isset($_POST['myform'])) { echo '<textarea rows="8" cols="60">'; $xml = new XMLWriter; $xml->openUri('php://output'); $xml->startDocument('1.0', 'UTF-8'); $xml->setIndent(true); foreach ($_POST['foo'] as $job) { $xml->startElement('job'); foreach($job as $k => $v) { $xml->writeElement($k, $v); } $xml->endElement(); } $xml->endDocument(); $xml->flush(); echo '</textarea>'; exit; } ?> <!doctype html> <head><title>XML demo</title></head> <body> <form method="post" action="" enctype="application/x-www-form-urlencoded"> <p> <label>Title</label> <input type="text" name="foo[0][title]"><br> <label>Description</label> <input type="text" name="foo[0][description]"><br> <label>Place</label> <input type="text" name="foo[0][place]"><br> </p> <p> <label>Title</label> <input type="text" name="foo[1][title]"><br> <label>Description</label> <input type="text" name="foo[1][description]"><br> <label>Place</label> <input type="text" name="foo[1][place]"><br> </p> <p><input type="submit" name="myform" value="Submit"> </form> </body>
Show:  
Copy Clear