In DOMIT!, a DOM Document is represented by the DOMIT_Document class.
Below is an example of the cd collection XML string from the previous page being instantiated as a DOMIT_Document.
- First, the DOMIT_Document is created and assigned to the variable $cdCollection.
- Then the XML string is passed to the parseXML method.
$cdCollectionString = "<cdlibrary><cd id=\"0001\">
<name>Robbie Fulks</name>
<title>Couples in Trouble</title></cd>
<cd id=\"0002\"><name>Richard Thompson</name>
<title>Mock Tudor</title></cd><cd id=\"0003\">
<name>Keller Williams</name>
<title>Laugh</title></cd></cdlibrary>\";
$cdCollection =& new DOMIT_Document();
$success = $cdCollection->parseXML($cdCollectionString, true);
Note that the second parameter to the parseXML method should be set to true if you wish to use the SAXY parser instead of the Expat browser.
parseXML returns true if the parsing is successful.
|