Next / Previous / Contents / TCC Help System / NM Tech homepage

3.2. A full-featured reader

In the cases where your document needs a correct base URI, use this form of import:

from Ft.Xml.Domlette import NonvalidatingReader

In case you're wondering, there is also a ValidatingReader that uses the document's <!DOCTYPE> declaration to find its schema, and validates the document against the schema. We'll assume that validation is taken care of elsewhere.

Then, to turn that document into a DOM tree, use one of these methods:

NonvalidatingReader.parseURI ( uri )

Read the document from a given URI. The uri argument specifies the document's location as well as its base URI.

NonvalidatingReader.parseStream ( f, uri )

Read the document from a readable file object f. The uri argument must be the document's base URI.

NonvalidatingReader.parseString ( s, uri )

The s argument is a string containing the entire document. The uri argument must be the document's base URI.

Each of these reader functions returns a Document instance.