The xml2rfc parser module contains two classes for public use: XmlRfcParser and XmlRfc.
XmlRfcParser is a basic XML parser which uses the lxml library to parse an xml file into a tree structure. An instance of XmlRfc contains a reference to this parsed tree, along with some helper methods to provide useful additional formatting to the tree.
Accessing nodes in the tree is done through the standard lxml.etree interface. You can read more about that at the lxml documentation
Example – getting the title of an rfc document:
root = xmlrfc.getroot()
title = root.find('front/title').text
XML parser with callbacks to construct an RFC tree
Parses the source XML file and returns an XmlRfc instance
Internal representation of an RFC document
Contains an lxml.etree.ElementTree, with some additional helper methods to prepare the tree for output.
Accessing the rfc tree is done by getting the root node from getroot()
Returns a list of the XML processing instructions
Wrapper method to get the root of the XML tree
Add a processing instruction to the current state
Will also return the dictionary containing the added instructions for use in things like ?include instructions
Traverses the RFC tree and replaces unicode characters with the proper equivalents specified in rfc2629-xhtml.ent.
Writers should call this method if the entire RFC document needs to be ascii formatted
Validate the document with its default dtd, or an optional one
Return a success bool along with a list of any errors
Application XML errors with positional information
This class attempts to mirror the API of lxml’s error class