python - pyparsing OneOrMore().asxml() tags are not correct -


when use asxml() output parsedresults xml tags not match have specified in setresultsname().

example:

#!/usr/bin/python import sys import os pyparsing import *  mystring=""" b c x y z """ parserelement.setdefaultwhitespacechars(" \t\r") sol = linestart().leavewhitespace().suppress() eol = lineend().suppress()  first = sol + word(alphas)('first') second = word(alphas)('second') third = word(alphas)('third') + eol line = group(first + second + third).setresultsname('line')  print oneormore(line).setresultsname('mylines').searchstring(mystring).asxml() 

and output

<item>   <mylines>     <mylines>       <first>a</first>       <second>b</second>       <third>c</third>     </mylines>     <line>       <first>x</first>       <second>y</second>       <third>z</third>     </line>   </mylines> </item> 

why there 1 mylines tag nested in @ top next block line tag expecting ?


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -