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
2
votes
0 answers

Python xmltodict indicies error

I have this XML API I am trying to get information out of for stats. Here's my code and sample XML: xml.xml John Doe
Pat
  • 1,173
  • 5
  • 19
  • 44
1
vote
0 answers

XML file creation with Python: How to display the attributes of an element in multiple lines

I am working with python on the creation of two types of files: EVFM and SMURF, which both follow the xml structure. One example of such files is the following: EVFM My approach is to use the xmltodict package with the unparse method, which…
1
vote
2 answers

Best means to parse through multiple subelements within XML

I am attempting to use xmltodict to parse through XML in to hopes of eventually converting to a more readable table format for others. I have been able to get through most of the XML but when I come to an element with multiple subelements, I feel I…
gritts
  • 177
  • 1
  • 3
  • 13
1
vote
0 answers

how to install python module on dataproc cluster executors

how can we import xmltodict module to all worker nodes of cluster, now it's giving me error as ' no name module ' while performing xmltodict on pyspark dataframe xmltodict python module should be install on all executors of dataproc cluster
1
vote
1 answer

Python Dictionary - Looping issue (nested) | TypeError: list indices must be integers or slices, not str

I am trying to loop over a nested dictionary but keep getting the error: list indices must be integers or slices, not str. This is the data I am trying to loop over and have converted to a dictionary with using xmltodict:
1
vote
1 answer

Python command-line one-liner using xmltodict to convert XML to JSON

I am trying to write a Python one-liner using xmltodict to convert an XML file to JSON. It seems like there's an issue reading from sys.stdin directly or as sys.stdin.buffer.read(): python -c 'import xmltodict, sys, json;…
asterisk
  • 13
  • 3
1
vote
2 answers

How to remove @ prefix while converting xml to json in Python

I'm trying to convert xml to json in python using xmltodict library. Though, the xml is getting converted to json, before every key in dict, '@' is getting prefixed. Below is the code snippet and sample output: import xmltodict import json with…
Sumit
  • 1,360
  • 3
  • 16
  • 29
1
vote
1 answer

Python xmltodict with multiple OrderedDictkeys

Is there any way to create xml output that given a multiple OrderedDict like this data = OrderedDict([ ... ('addresses', OrderedDict([ ('address', OrderedDict([ ('city', 'Washington') ])), ('address',…
jackquin
  • 534
  • 1
  • 7
  • 19
1
vote
1 answer

Error when parsing XML document using xmltodict python

I've copied over an XML document below, which is titled 'dictionary.xml' For some reason, the document cannot be parsed by XmlToDict in python.
user12339101
1
vote
1 answer

ModuleNotFoundError: No module named 'xmltodict'

I have installed xmltodict successfully using the below command python -m pip install --upgrade --user xmltodict But when I am executing a python script which contains import xmltodict I am getting the below error import…
Jai
  • 21
  • 1
  • 4
1
vote
1 answer

cannot parse json to xml using xmltodict.unparse when converting json list

Trying to do this using xmltodict.unparse: I have this structure in json: "organisations": [ {"organisation": "org1"}, {"organisation": "org2"}, {"organisation": "org3"} ] But comes out like this in…
Elias
  • 81
  • 1
  • 13
1
vote
2 answers

xmltodict with force_list argument returns a list with None element for empty XML list

I'm parsing XML with xmltodict with force_list=('xml_tag') in order to get list for single elements in XML list. And it works! However, in case when xml_tag has no child it returns a [None](list with single None object). How to prevent it? …
catscoolzhyk
  • 675
  • 10
  • 29
1
vote
1 answer

Display XML Data Using Python

Attempting to create a python script to display data from a complex XML file that changes every 5-7 seconds. Below is a sample XML file that I'm working with...
1
vote
1 answer

xmltodict: ExpatError: syntax error: line 1, column 0, getting xml from QuickGO

I'm finding myself a bit confused by the error I get from the following from future.standard_library import install_aliases install_aliases() from urllib.request import urlopen import xmltodict oboxml =…
Jeff S.
  • 87
  • 2
  • 11
1
vote
1 answer

xmltodict unparse parse not the same

import xmltodict test_data = {'value1': 1, 'parent_lvl1': {'parent_Lvl2': {'value1': 2, 'value2': 3}}} print("test_data : ", test_data) xml_str = xmltodict.unparse({'settings' : test_data}) print("dict to xml string :", xml_str) test_data_re =…
Leon Hough
  • 53
  • 4