Next Nov 6 PreviousRoads to Rome
You need to process an XML file using DOM. Which method(s) can you use to create a DOM object from the XML data. Choose al that apply.
A: DOMDocument::load()
B: DOMDocument::loadXML()
C: domxml_open_mem()
D: domxml_open_file()
Answer
You can use all functions to create a DOM object from XML data. The following code sample shows you some applications of each function:
<?php
$xmlFile = "data.xml";
$xmlData = file_get_contents($xmlFile);
$domA1 = new DomDocument();
$domA1->load($xmlFile);
$domA2 = DomDocument::load($xmlFile);
$domB1 = new DomDocument();
$domB1->loadXML($xmlData);
$domB2 = DomDocument::loadXML($xmlData);
$domC = domxml_open_mem($xmlData);
$domD = domxml_open_file($xmlFile);
?>