May-16-2021, 09:31 PM
Here e demo of using lxml with xPath.
Can either parse the full file into a DOM, or use Sax callbacks to parse serially.
Try some stuff and see how it goes.
from lxml import etree root = etree.parse('W2Testfile.xml') sub = root.xpath('//SubmissionId')[0] print(sub.text) for tag in root.xpath('//DependentRelationshipCd'): print(tag.text)
00000000000000002222 SON HALF BROTHER HALF BROTHER STEPCHILD
MDRI Wrote:We may have 45K to 50K xml elements to traverse this way.Not that large would not cause any problems.
MDRI Wrote:Is lxml work as DOM serial parsing ? How will address of pulling all this big XML into DOM?lxml can operate in either mode,it just depends how your code uses it.
Can either parse the full file into a DOM, or use Sax callbacks to parse serially.
MDRI Wrote:Are there any options in Python do parallel parsing like SAX (Java)?Yes serval ways eg concurrent.futures
Try some stuff and see how it goes.