Package libxml2dom
[show private | hide private]
[frames | no frames]

Package libxml2dom

DOM wrapper around libxml2, specifically the libxml2mod Python extension module.

Copyright (C) 2003, 2004, 2005, 2006, 2007 Paul Boddie <paul@boddie.org.uk>

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
details.

You should have received a copy of the GNU Lesser General Public License along
with this program.  If not, see <http://www.gnu.org/licenses/>.

Submodules
  • events: DOM Level 3 Events support, with SVG Tiny 1.2 implementation additions.
  • macrolib: DOM macro library for libxml2.
    • macrolib: DOM macros for virtual libxml2mod node methods and properties.
  • svg: SVG-specific document support.
  • xmpp: XMPP support using libxml2dom to capture stanzas as documents.

Classes
Attribute A class providing attribute access.
Document A generic document class.
DocumentType A class providing a container for document type information.
Implementation Contains an abstraction over the DOM implementation.
NamedNodeMap A wrapper around Node objects providing DOM and dictionary convenience methods.
NamedNodeMapIterator An iterator over a NamedNodeMap.
Node A DOM-style wrapper around libxml2mod objects.
NodeList A wrapper around node lists.

Function Summary
  adoptNodes(nodes, impl)
A special utility method which adopts the given low-level 'nodes' and which returns a list of high-level equivalents.
  createDocument(namespaceURI, localName, doctype)
  createDocumentType(localName, publicId, systemId)
  getDOMImplementation()
Return the default DOM implementation.
  parse(stream_or_string, html, htmlencoding, unfinished, impl)
Parse the given 'stream_or_string', where the supplied object can either be a stream (such as a file or stream object), or a string (containing the filename of a document).
  parseFile(filename, html, htmlencoding, unfinished, impl)
Parse the file having the given 'filename'.
  parseString(s, html, htmlencoding, unfinished, impl)
Parse the content of the given string 's'.
  parseURI(uri, html, htmlencoding, unfinished, impl)
Parse the content found at the given 'uri'.
  toFile(node, filename, encoding, prettyprint)
Write the serialised form of the given 'node' and its children to a file having the given 'filename'.
  toStream(node, stream, encoding, prettyprint)
Write the serialised form of the given 'node' and its children to the given 'stream'.
  toString(node, encoding, prettyprint)
Return a string containing the serialised form of the given 'node' and its children.

Function Details

adoptNodes(nodes, impl=None)

A special utility method which adopts the given low-level 'nodes' and which
returns a list of high-level equivalents. This is currently experimental and
should not be casually used.

getDOMImplementation()

Return the default DOM implementation.

parse(stream_or_string, html=0, htmlencoding=None, unfinished=0, impl=None)

Parse the given 'stream_or_string', where the supplied object can either be
a stream (such as a file or stream object), or a string (containing the
filename of a document). The optional parameters described below should be
provided as keyword arguments.

If the optional 'html' parameter is set to a true value, the content to be
parsed will be treated as being HTML rather than XML. If the optional
'htmlencoding' is specified, HTML parsing will be performed with the
document encoding assumed to that specified.

If the optional 'unfinished' parameter is set to a true value, unfinished
documents will be parsed, even though such documents may be missing content
such as closing tags.

A document object is returned by this function.

parseFile(filename, html=0, htmlencoding=None, unfinished=0, impl=None)

Parse the file having the given 'filename'. The optional parameters
described below should be provided as keyword arguments.

If the optional 'html' parameter is set to a true value, the content to be
parsed will be treated as being HTML rather than XML. If the optional
'htmlencoding' is specified, HTML parsing will be performed with the
document encoding assumed to that specified.

If the optional 'unfinished' parameter is set to a true value, unfinished
documents will be parsed, even though such documents may be missing content
such as closing tags.

A document object is returned by this function.

parseString(s, html=0, htmlencoding=None, unfinished=0, impl=None)

Parse the content of the given string 's'. The optional parameters described
below should be provided as keyword arguments.

If the optional 'html' parameter is set to a true value, the content to be
parsed will be treated as being HTML rather than XML. If the optional
'htmlencoding' is specified, HTML parsing will be performed with the
document encoding assumed to that specified.

If the optional 'unfinished' parameter is set to a true value, unfinished
documents will be parsed, even though such documents may be missing content
such as closing tags.

A document object is returned by this function.

parseURI(uri, html=0, htmlencoding=None, unfinished=0, impl=None)

Parse the content found at the given 'uri'. The optional parameters
described below should be provided as keyword arguments.

If the optional 'html' parameter is set to a true value, the content to be
parsed will be treated as being HTML rather than XML. If the optional
'htmlencoding' is specified, HTML parsing will be performed with the
document encoding assumed to that specified.

If the optional 'unfinished' parameter is set to a true value, unfinished
documents will be parsed, even though such documents may be missing content
such as closing tags.

XML documents are retrieved using libxml2's own network capabilities; HTML
documents are retrieved using the urllib module provided by Python. To
retrieve either kind of document using Python's own modules for this purpose
(such as urllib), open a stream and pass it to the parse function:

f = urllib.urlopen(uri)
try:
    doc = libxml2dom.parse(f, html)
finally:
    f.close()

A document object is returned by this function.

toFile(node, filename, encoding=None, prettyprint=0)

Write the serialised form of the given 'node' and its children to a file
having the given 'filename'. The optional 'encoding' can be used to override
the default character encoding used in the serialisation. The optional
'prettyprint' indicates whether the serialised form is prettyprinted or not
(the default setting).

toStream(node, stream, encoding=None, prettyprint=0)

Write the serialised form of the given 'node' and its children to the given
'stream'. The optional 'encoding' can be used to override the default
character encoding used in the serialisation. The optional 'prettyprint'
indicates whether the serialised form is prettyprinted or not (the default
setting).

toString(node, encoding=None, prettyprint=0)

Return a string containing the serialised form of the given 'node' and its
children. The optional 'encoding' can be used to override the default
character encoding used in the serialisation. The optional 'prettyprint'
indicates whether the serialised form is prettyprinted or not (the default
setting).

Generated by Epydoc 2.1 on Tue Sep 18 23:37:02 2007 http://epydoc.sf.net