0"?>
John Doe
1234567890123456
01/06
01/09
100
Mastercard
The DOMDocument class is used to work with XML data; this class knows how to create, read, and manipulate XML
documents without much effort from the developer. The Document Object Model (DOM) is the most important and
versatile tree-model XML-parsing application programming interface (API).
?– Tip The World Wide Web Consortium manages the DOM standard; its official web page is
http://www.w3.org/DOM/.
CHAPTER 16 ?– MANAGING CUSTOMER DETAILS 496
With the new PHP 5 DOM extension, reading, creating, editing, saving, and searching XML documents from PHP
has never been easier. The DOM extension in PHP 5 was entirely rewritten from scratch to fully comply with the
DOM specifications. You can see this extension in action in the CreateXml() method, which creates an XML
document with the structure shown earlier by creating nodes and setting their values:
// Create XML with credit card information
private function CreateXml()
{
// Encode card details as XML document
$xml_card_data = &$this->_mXmlCardData;
$xml_card_data = new DOMDocument();
$document_root = $xml_card_data->createElement('CardDetails');
$child = $xml_card_data->createElement('CardHolder');
$child = $document_root->appendChild($child);
$value = $xml_card_data->createTextNode($this->_mCardHolder);
$value = $child->appendChild($value);
.
Pages:
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618