class documentation

class XmlBuilder(object): (source)

Constructor: XmlBuilder()

View In Hierarchy

XML parser for custom XML structures.

Parses arbitrary XML into a nested dictionary/list structure with tag names, attributes, cdata, and child tags.

Method __init__ Constructor.
Method OnCharacterData Handle character data from the XML parser.
Method OnComment Handle an XML comment (ignored).
Method OnEndCData Handle end of a CDATA section.
Method OnEndElement Handle the end of an XML element.
Method OnEndNamespaceDecl Handle end of a namespace declaration (ignored).
Method OnProcessingInstruction Handle a processing instruction (ignored).
Method OnStartCData Handle start of a CDATA section.
Method OnStartElement Handle the start of an XML element.
Method OnStartNamespaceDecl Handle start of a namespace declaration (ignored).
Method parse Parse a given XML document into a nested tag structure.
Class Variable iBufferSize Undocumented
Instance Variable bInCData Undocumented
Instance Variable dTagStack Undocumented
def __init__(self): (source)

Constructor.

def OnCharacterData(self, sData): (source)

Handle character data from the XML parser.

Appends character data to the current tag's cdata buffer.

Parameters
sData:strCharacter data string
def OnComment(self, data): (source)

Handle an XML comment (ignored).

Parameters
data:strComment string
def OnEndCData(self): (source)

Handle end of a CDATA section.

def OnEndElement(self, sTagName): (source)

Handle the end of an XML element.

Pops the current tag, assembles it into a structured dict, and appends it to the parent tag's children.

Parameters
sTagName:strElement (tag) name
Raises
ParseErrorIf end tag does not match the expected start tag
def OnEndNamespaceDecl(self, prefix): (source)

Handle end of a namespace declaration (ignored).

Parameters
prefix:strNamespace prefix
def OnProcessingInstruction(self, target, data): (source)

Handle a processing instruction (ignored).

Parameters
target:strProcessing instruction target
data:strProcessing instruction data
def OnStartCData(self): (source)

Handle start of a CDATA section.

def OnStartElement(self, sTagName, dTagAttrs): (source)

Handle the start of an XML element.

Pushes a new tag dictionary onto the tag stack.

Parameters
sTagName:strElement (tag) name
dTagAttrs:dictDictionary of element attributes
def OnStartNamespaceDecl(self, prefix, uri): (source)

Handle start of a namespace declaration (ignored).

Parameters
prefix:strNamespace prefix
uri:strNamespace URI
def parse(self, input): (source)

Parse a given XML document into a nested tag structure.

Parameters
input:bytes or file-likeXML document as string or file object
Returns
listList of parsed tags
Raises
ParseErrorIf the XML document contains syntax errors
iBufferSize = (source)

Undocumented

bInCData: int = (source)

Undocumented

dTagStack = (source)

Undocumented