Members

Note: You can use your Sitellite.org account here and vice versa.

Username

Password

Remember Login

Forgot your password?

Not a member? Click here to register

Sloppy Dom Parser

Home Page | All Pages | Recently Revised | Authors | Feeds |

Sloppy is a misnomer in that the SloppyDOM parser isn't sloppy at all. SloppyDOM is a lightweight XML parser that creates an in-memory copy of an XML document using the XMLDoc class. This allows parsing of small XML documents to be parsed and modified quickly and easily. The actual XML parsing occurs via PHP's built-in XML extension, but the resulting object is of the XMLDoc class, found in saf.XML.Doc.

SloppyDOM works like this:


<?php

// first, we need a sample XML document in a string
$xml_data = '<html><head><title>Hello</title></head></html>';

// import the Sloppy package
loader_import ('saf.XML.Sloppy');

// create a new instance of the SloppyDOM object
$parser = new SloppyDOM ();

// parse the document
if ($document =& $parser->parse ($xml_data) {
    // we now have a copy of the document in memory
    echo $document->_html->_head->_title->content;
} else {
    // there was a document parsing error, let's see it
    echo $parser->error;
}

?>

For more information:

Revised on June 11, 2005 10:59 PM by anonymous

Back in time (1 more) | Linked from: X M L