Writing xml with php

hedAnnobe

New Member
I don't know where my error comes from, i am new to xml and i need some help.I want to write an xml file using php. I have the following php code:\[code\]<?php $xml = array(); $xml [] = array( 'error' => 'ERROR_ID' ); $doc = new DOMDocument(); $doc->formatOutput = true; $r = $doc->createElement( "xml" ); $doc->appendChild( $r ); $parameters = $doc->createElement( "parameters" ); $error = $doc->createElement( "error" ); $error->appendChild( $doc->createTextNode( $xml['error'] ) ); $parameters->appendChild( $error ); $r->appendChild( $parameters ); echo $doc->saveXML(); $doc->save("write.xml") ?>\[/code\]My xml file should look like this:\[code\]<?xml version="1.0"?><xml> <parameters> <error>ERROR_ID</error> </parameters></xml>\[/code\]but the ERROR_ID text node doesn't show up in the file.What went wrong?
 
Back
Top