I am a beginner in PHP and XML.
Can somebody tell me how to include XML encoding when I write a new xml file.
Here are the codes:
writexml.php
<?php
$ids = array("1", "2", "3", "4", "5");
$names = array("Jean Claude Van Damme", "Scott Adkins", "Dolph Ludgren", "Michael Jai White", "Michael Worth");
$domdoc = new DOMDocument();
$domdoc->formatOutput = true;
$el_actionstars = $domdoc->createElement( "actionstars" );
$domdoc->appendChild( $el_actionstars );
$arr_size = count($ids);
for ($i=0; $i < $arr_size; $i++) {
$el_actionstar = $domdoc->createElement( "actionstar" );
$el_id = $domdoc->createElement( "id" );
$el_id->appendChild( $domdoc->createTextNode($ids[$i] . ""));
$el_actionstar->appendChild($el_id);
$el_name = $domdoc->createElement( "name" );
$el_name->appendChild( $domdoc->createTextNode($names[$i] . ""));
$el_actionstar->appendChild($el_name);
$el_actionstars->appendChild($el_actionstar);
}
echo $domdoc->saveXML();
$domdoc->save("actionstars.xml")
?>
The xml output is <?xml version="1.0"?>
and I want to add the encoding to make it look like <?xml version="1.0" encoding="ISO-8859-1"?>
. Pls help...