def asXML( self, doctag=None, namedItemsOnly=False, indent="<STR_LIT>", formatted=True ):
nl = "<STR_LIT:\n>"<EOL>out = []<EOL>namedItems = dict((v[<NUM_LIT:1>],k) for (k,vlist) in self.__tokdict.items()<EOL>for v in vlist)<EOL>nextLevelIndent = indent + "<STR_LIT:U+0020>"<EOL>if not formatted:<EOL><INDENT>indent = "<STR_LIT>"<EOL>nextLevelIndent = "<STR_LIT>"<EOL>nl = "<STR_LIT>"<EOL><DEDENT>selfTag = None<EOL>if doctag is not None:<EOL><INDENT>selfTag = doctag<EOL><DEDENT>else:<EOL><INDENT>if self.__name:<EOL><INDENT>selfTag = self.__name<EOL><DEDENT><DEDENT>if not selfTag:<EOL><INDENT>if namedItemsOnly:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>selfTag = "<STR_LIT>"<EOL><DEDENT><DEDENT>out += [ nl, indent, "<STR_LIT:<>", selfTag, "<STR_LIT:>>" ]<EOL>worklist = self.__toklist<EOL>for i,res in enumerate(worklist):<EOL><INDENT>if isinstance(res,ParseResults):<EOL><INDENT>if i in namedItems:<EOL><INDENT>out += [ res.asXML(namedItems[i],<EOL>namedItemsOnly and doctag is None,<EOL>nextLevelIndent,<EOL>formatted)]<EOL><DEDENT>else:<EOL><INDENT>out += [ res.asXML(None,<EOL>namedItemsOnly and doctag is None,<EOL>nextLevelIndent,<EOL>formatted)]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>resTag = None<EOL>if i in namedItems:<EOL><INDENT>resTag = namedItems[i]<EOL><DEDENT>if not resTag:<EOL><INDENT>if namedItemsOnly:<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>resTag = "<STR_LIT>"<EOL><DEDENT><DEDENT>xmlBodyText = _xml_escape(_ustr(res))<EOL>out += [ nl, nextLevelIndent, "<STR_LIT:<>", resTag, "<STR_LIT:>>",<EOL>xmlBodyText,<EOL>"<STR_LIT>", resTag, "<STR_LIT:>>" ]<EOL><DEDENT><DEDENT>out += [ nl, indent, "<STR_LIT>", selfTag, "<STR_LIT:>>" ]<EOL>return "<STR_LIT>".join(out)<EOL>
Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.