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 library 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 2.1 of the License, or (at your option) any later version.

This library 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 library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA

Submodules
  • events: DOM events support.
  • macrolib: DOM macro library for libxml2.
    • macrolib: DOM macros for virtual libxml2mod node methods and properties.
  • svg: SVG-specific document support.

Classes
Attribute A class providing attribute access.
Document A class providing document-level housekeeping.
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.
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, 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, impl)
Parse the file having the given 'filename'.
  parseString(s, html, htmlencoding, impl)
Parse the content of the given string 's'.
  parseURI(uri, html, htmlencoding, 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.

Variable Summary
str __version__ = '0.4'
Implementation default_impl = <libxml2dom.Implementation object at 0xb7...
list null_value_node_types = [9, 10, 1, 6, 5, 12]

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, 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). 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.

A document object is returned by this function.

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

Parse the file having the given 'filename'. 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 be that
specified.

A document object is returned by this function.

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

Parse the content of the given string 's'. 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 be that
specified.

A document object is returned by this function.

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

Parse the content found at the given 'uri'. 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 be that
specified.

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).

Variable Details

__version__

Type:
str
Value:
'0.4'                                                                  

default_impl

Type:
Implementation
Value:
<libxml2dom.Implementation object at 0xb7baffec>                       

null_value_node_types

Type:
list
Value:
[9, 10, 1, 6, 5, 12]                                                   

Generated by Epydoc 2.1 on Mon Mar 19 01:08:53 2007 http://epydoc.sf.net