Does Anyone Have Any Experience Parsing XML with Python??

Jan 12, 2016 03:15 PM

I dont want to waste anybodys time here but i will upload a sample of my xml file and the code i am trying to use to parse it, if anybody can tell me what im doing wrong i would be insanely grateful

xml sample:







10

12.1200







SINGLE

1.000

1.69



I am trying to extract the PurchaseOrderUnitId ident attrib number, and the PurchaseOrderUnitQty, they eventually need formatted like this 6 digit id number/+Qty. But right now im just trying to pull the numbers out of the xml file

With this code:

import xml.etree.cElementTree as ET

tree = ET.ElementTree(file="c:\\users\\design\\desktop\\scripttest\\newsample.xml")

root = tree.getroot()

for PurchaseOrderUnit in root.findall('PurchaseOrderUnit'):

qty = PurchaseOrderUnit.findall('PurchaseOrderUnitQty').text

id = PurchaseOrderUnit.get('PurchaseOrderUnitId')

print id, qty

when i run it from the command prompt it doesnt output anything, no errors or nothing.

Related Articles

637263493835297420.jpg

How to Use Zero-Width Characters to Hide Secret Messages in Text (& Even Reveal Leaks)

636455706472146367.jpg

How to Hide DDE-Based Attacks in MS Word

Comments

No Comments Exist

Be the first, drop a comment!