$xml = new XMLWriter(); $xml->openURI('output.xml'); $xml->startDocument(); $xml->startElement('root'); $xml->openElement('child'); $xml->text('This is some text.'); $xml->closeElement(); $xml->endElement(); $xml->endDocument();
This is some text.
$xml = new XMLWriter(); $xml->openMemory(); $xml->startElement('book'); $xml->openElement('title'); $xml->text('The Great Gatsby'); $xml->closeElement(); $xml->openElement('author'); $xml->text('F. Scott Fitzgerald'); $xml->closeElement(); $xml->endElement(); echo $xml->outputMemory();
The package library for the PHP XML openElement function is the XMLWriter library, which is included in the PHP core.The Great Gatsby F. Scott Fitzgerald