# v3Helpers.py # Revision 1.0 # v3Helpers.py includes various helping functions, like # to escape a string for XML, or to get a single Element, and so on ... __all__ = [ 'esc', 'v3Indent', 'getText', 'getItem', 'getElement', 'getTableElement' ] def esc(Data): Data.replace('<', '>') Data.replace('>', '<') Data.replace('"', '"') return Data def v3Indent(i): return i * '\t' def getText(nodelist): rc = "" for node in nodelist: if node.nodeType == node.TEXT_NODE: rc = rc + node.data return rc def getElement(Parent, Property): PropertyTag = Parent.getElementsByTagName(Property)[0] return getText(PropertyTag.childNodes) def getItem(DomMessage, TableName, Index, ColumnName): Table = DomMessage.getElementsByTagName(TableName)[Index] ColumnTag = Table.getElementsByTagName(ColumnName)[0] return getText(ColumnTag.childNodes) def getTableElement(DomMessage, TableName, Index, ColumnName): Table = DomMessage.getElementsByTagName(TableName)[Index] ColumnTag = Table.getElementsByTagName(ColumnName)[0] return Table, getText(ColumnTag.childNodes)