note 87535 added to function.xmlwriter-write-element
| From: | googolplex at gmx dot net | Date: | Tue, 09 Dec 2008 14:08:23 +0000 |
| Subject: | note 87535 added to function.xmlwriter-write-element | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-147950@lists.php.net to get a copy of this message | ||
The function XMLWriter::writeElement is used to write an element (i.e. a XML tag, an [optional]
content, and a closing XML tag) in one line without sub-elements:
<?php
$oXMLout = new XMLWriter();
$oXMLout->openMemory();
$oXMLout->writeElement("quantity", 8);
$oXMLout->writeElement("price_per_quantity", 110);
print $oXMLout->outputMemory();
// produces:
// <quantity>8</quantity>
// <price_per_quantity>110</price_per_quantity>
?>
whereas if you want to include sub-elements you have to use the XMLWriter::startElement /
XMLWriter::endElement pair:
<?php
$oXMLout = new XMLWriter();
$oXMLout->openMemory();
$oXMLout->startElement("item");
$oXMLout->writeElement("quantity", 8);
$oXMLout->writeElement("price_per_quantity", 110);
$oXMLout->endElement();
print $oXMLout->outputMemory();
// produces:
// <item>
// <quantity>8</quantity>
// <price_per_quantity>110</price_per_quantity>
// </item>
?>
----
Server IP: 216.92.131.65
Probable Submitter: 195.125.144.60
----
Manual Page -- http://www.php.net/manual/en/function.xmlwriter-write-element.php
Edit -- https://master.php.net/note/edit/87535
Del: integrated -- https://master.php.net/note/delete/87535/integrated
Del: useless -- https://master.php.net/note/delete/87535/useless
Del: bad code -- https://master.php.net/note/delete/87535/bad+code
Del: spam -- https://master.php.net/note/delete/87535/spam
Del: non-english -- https://master.php.net/note/delete/87535/non-english
Del: in docs -- https://master.php.net/note/delete/87535/in+docs
Del: other reasons-- https://master.php.net/note/delete/87535
Reject -- https://master.php.net/note/reject/87535
Search -- https://master.php.net/manage/user-notes.php