def parse_string(xml):
string = "<STR_LIT>"<EOL>dom = XML(xml)<EOL>for sentence in dom(XML_SENTENCE):<EOL><INDENT>_anchors.clear()     <EOL>_attachments.clear() <EOL>language = sentence.get(XML_LANGUAGE, "<STR_LIT>")<EOL>format = sentence.get(XML_TOKEN, [WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA])<EOL>format = not isinstance(format, basestring) and format or format.replace("<STR_LIT:U+0020>","<STR_LIT>").split("<STR_LIT:U+002C>")<EOL>tokens = []<EOL>for chunk in sentence:<EOL><INDENT>tokens.extend(_parse_tokens(chunk, format))<EOL><DEDENT>if ANCHOR in format:<EOL><INDENT>A, P, a, i = _anchors, _attachments, <NUM_LIT:1>, format.index(ANCHOR)<EOL>for id in sorted(A.keys()):<EOL><INDENT>for token in A[id]:<EOL><INDENT>token[i] += "<STR_LIT:->"+"<STR_LIT:->".join(["<STR_LIT:A>"+str(a+p) for p in range(len(P[id]))])<EOL>token[i]  = token[i].strip("<STR_LIT>")<EOL><DEDENT>for p, pnp in enumerate(P[id]):<EOL><INDENT>for token in pnp: <EOL><INDENT>token[i] += "<STR_LIT:->"+"<STR_LIT:P>"+str(a+p)<EOL>token[i]  = token[i].strip("<STR_LIT>")<EOL><DEDENT><DEDENT>a += len(P[id])<EOL><DEDENT><DEDENT>tokens = ["<STR_LIT:/>".join([tag for tag in token]) for token in tokens]<EOL>tokens = "<STR_LIT:U+0020>".join(tokens)<EOL>string += tokens + "<STR_LIT:\n>"<EOL><DEDENT>try:<EOL><INDENT>if MBSP: from mbsp import TokenString<EOL>return TokenString(string.strip(), tags=format, language=language)<EOL><DEDENT>except:<EOL><INDENT>return TaggedString(string.strip(), tags=format, language=language)<EOL><DEDENT>
Returns a slash-formatted string from the given XML representation.
        The return value is a TokenString (for MBSP) or TaggedString (for Pattern).