Questions tagged [xmltodict]

Python module that makes working with XML feel like you are working with JSON.

xmltodict is a Python module that makes working with XML feel like you are working with JSON

Check it on Pypi here.

120 questions
1
vote
0 answers

Python Parse xml file using xmltodict and add it to list

I want to load and parse a xml file using xmltoDic and add it to a python list my python file import xmltodict with open('input.xml') as fd: my_dict= xmltodict.parse(fd.read()) entries = my_dict['Drivetrain']['Element'] elements=[] for k in…
user17970
  • 495
  • 1
  • 9
  • 25
1
vote
1 answer

attributes not appearing in xml2dict parse output even with xml_attribs = True

I am having a problem with python xmltodict. Following the near-consensus recommendation here, I tried xmltodict and liked it very much until I had to access attributes at the top level of my handler. I'm probably doing something wrong but it's not…
Steve Cohen
  • 4,679
  • 9
  • 51
  • 89
1
vote
1 answer

Python extract values from list of OrderedDicts

I have parsed an XML file with xmltodict, and I have the discovered the path to the tag from which I wish to extract lat & long values to add to a dataframe. Here is a small sample:
user6901894
1
vote
0 answers

xmltodict fails on the first line of an xml file

This line in a python script: result = xmltodict.parse('path/to/schema.xml', encoding='utf-8') generates this error: johnnyb@verahost ~/SignalDB $ python3 xmltest.py Traceback (most recent call last): File "xmltest.py", line 13, in
Omortis
  • 1,334
  • 19
  • 44
1
vote
2 answers

xmltodict convert nonetype output to list

I have a basic example from xmltodict which closely follows the examples given on the project github page. def handle(_, book): print(book['title']) return True with open(r'C:\Users\u369811\books.xml', 'r') as f: FILE = f.read() …
sayth
  • 6,696
  • 12
  • 58
  • 100
1
vote
1 answer

Using xmltodict for Python, how can I reference a non-specific XML property and change the value?

I have an xml file as such: Is it possible, using xmltodict, to find…
1
vote
1 answer

xmltodict: Not fetching correct nested elements

So I have an XML like that:
Amazon .. 1 Jhon 2 Jhon
Volatil3
  • 14,253
  • 38
  • 134
  • 263
1
vote
1 answer

Sample XML of same structure parses differently to Full XML

I earlier posted a question on SO which contained abbreviated sample XML to allow testing, I edited the repetitious content of the XML to allow it to be posted. The XML insert I posted was
sayth
  • 6,696
  • 12
  • 58
  • 100
1
vote
1 answer

xmltodict after parse only 1 root key and all other data in 2nd key

Am I doing something wrong with importing with xmltodict. When I am importing the data I am receiving only 2 items the first the root level object and the 2nd the rest of the values. In [58]: with open('20160305RAND0_edit.xml') as f: ....: my…
sayth
  • 6,696
  • 12
  • 58
  • 100
1
vote
1 answer

Error with xmltodict

EDIT: I can print rev['contributor'] for a while but then every try to access rev['contributor'] returns the following TypeError: string indices must be integers ORIGINAL POST: I'm trying to extract data from an xml using xml to dict with the…
Knokkelgeddon
  • 211
  • 1
  • 14
1
vote
1 answer

Python: Get value with xmltodict

I have an XML-file that looks like this: Jake Roberts
JakeRoberts
  • 53
  • 2
  • 9
1
vote
1 answer

python xml2dict complex xml

I have a huge and complex xml document that I wanted to parse into a dictionary (and later on into a db with sqlalchemy). I want to use xmltodict for this task. However, it seems that xmltodict cannot parse deeply nested xml directly. My MWE: …
absurd
  • 1,035
  • 3
  • 14
  • 35
1
vote
1 answer

How to convert dict to suds complex suds type

I am trying to send a request to a soap server, using suds which should look like this:
hzrari
  • 1,803
  • 1
  • 15
  • 26
1
vote
0 answers

Improve parsing speed for xmltodict

I have a compressed FIXML ZIP file. I am trying to use xmltodict to parse its uncompressed file (~130MB uncompressed data) as follows, but the parsing takes about 3 mins: with zipfile.ZipFile(ff, 'r') as fh: infile = fh.read(fh.namelist()[0]) o…
prd999
  • 167
  • 1
  • 8
0
votes
1 answer

File cannot be parsed and uploaded to Azure in the same function

I have this code snippet in Python/Flask where the user can upload multiple files and I want to parse the XML file first and then upload the file to Azure: import xmltodict def function1(): files = request.files.getlist("file") for…
rikitikitik
  • 2,414
  • 2
  • 26
  • 37