I need to parse the xml comment file. In particular, it is a C # file using the MS ///
convention.
From this I need to get foobar
, or /// foobar
will be acceptable too. (Note - this still doesn't work if you do xml all on one line ...)
testStr = """ ///<summary> /// foobar ///</summary> """
Here is what I have:
import pyparsing as pp _eol = pp.Literal("\n").suppress() _cPoundOpenXmlComment = Suppress('///<summary>') + pp.SkipTo(_eol) _cPoundCloseXmlComment = Suppress('///</summary>') + pp.SkipTo(_eol) _xmlCommentTxt = ~_cPoundCloseXmlComment + pp.SkipTo(_eol) xmlComment = _cPoundOpenXmlComment + pp.OneOrMore(_xmlCommentTxt) + _cPoundCloseXmlComment match = xmlComment.scanString(testStr)
and for output:
for item,start,stop in match: for entry in item: print(entry)
But I did not have much success with a grammar working with multiple lines.
(note - I tested the above sample in python 3.2, it works, but (by my problem) does not print any values)
Thanks!
source share