I'm having trouble with simpleXML. When I send form information to the XML document it just stays on the same line in the XML document. I thinks its something to with creating a new Element but i'm lost :). I want the form tag as the root and person tag as the child of the root and the others the children of person Have a look below. Thanks.
XML code is below:
<?xml version="1.0"?> <?xml-stylesheet href="form.xsl" type="text/xsl"?> <form> <person><name>help</name><favteam>help</favteam><winner>help</winner></form> PHP Code is below:
$xml = simplexml_load_file('form.xml'); $xmlFormat = $xml->asXML(); $newChild = $xml->addChild('person'); $newChild->addChild('name', $name); $newChild->addChild('favteam', $name); $newChild->addChild('winner', $name); $newChild->addChild('comment', $name);
No comments:
Post a Comment