Friday, May 17, 2013

File XML dengan php 2

< ?php
//$xml = new XMLWriter();
//$xml->openMemory();
//$xml->startDocument('1.0','UTP-8');


$fileName = 'members.xml';

$xml = new XMLWriter();
$xml->openMemory();
$xml->startDocument('1.0', 'UTF-8');

//members
$xml->startElement('members');

    //member
    $xml->startElement('member');
    $xml->writeAttribute('id',1);
    $xml->writeAttribute('position','treasurer');

        //firstname
        $xml->startElement('firstName');
        $xml->text('Apri');
        $xml->endElement();
        //lastname
        $xml->startElement('lastName');
        $xml->text('Suharto');
        $xml->endElement();
        //score
        $xml->startElement('score');
        $xml->text('99');
        $xml->endElement();
    //close member
    $xml->endElement();

//close members
$xml->endElement();

//write to file
file_put_contents('members.xml', $xml->outputMemory());

//end document
$xml->endDocument();


? >

No comments:

Post a Comment