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

Read, Modify the xml save it in a new xml using python

Below are the steps I am following: Reading the xml file as dictionary import xmltodict with open("example.xml") as sxml: data = xmltodict.parse(sxml.read()) Changing the value data["key"]["key1"] = "some value" I want to save the changes in…
Raswanth
  • 41
  • 1
  • 2
3
votes
1 answer

Python xmltodict Force Array with attribute

I've been using the python package xmltodict very successfully to parse my xml string into a python dictionary. However, I have the following issue: ["a","b"] parses as: { child: { episode: ["a","b"] …
user988029
  • 75
  • 1
  • 8
3
votes
2 answers

Creating a json file from a xml file in python with xmltodict

I am trying to create a json file from an input xml file using xmltodict with the following code import io, xmltodict, json infile = io.open(filename_xml, 'r') outfile = io.open(filename_json, 'w') o = xmltodict.parse( infile.read() ) json.dump( o ,…
RockridgeKid
  • 145
  • 3
  • 11
2
votes
1 answer

Python xmltodict shows inconsistent behaviour in XML arrays

I seen some, IMHO, inconsistent behaviour in Python xmltodoct.parse function. When an array has only 1 element, it returns an iterator with the child-elements When an array has more than 1 element, it returns an iterator with the elements in…
BertC
  • 2,243
  • 26
  • 33
2
votes
2 answers

How to convert the http get response from html to json format (from kaggle.com)

I tried below code to get a http response from kaggle.com. Kaggle response is in html format and I wanted to convert it to json format for the ease of further processing. import requests import json username = 'vgtgayan' base_url =…
V.G.T. Gayan
  • 25
  • 1
  • 6
2
votes
0 answers

MemoryError using xmltodict in Python

I'm trying to parse an XML file HMDB the Saliva Metabolites dataset into a list of dictionaries. Doing so, using the xmldict package. The format of the data and the output structure I try to create is in the first to code paragraphs in previews…
TaL
  • 173
  • 2
  • 15
2
votes
1 answer

how to explode dict (or list of dict) object in multiple column in dask.dataframe

When I try to convert some xml to dataframe using xmltodict it happens that a particular column contains all the info I need as dict or list of dict. I'm able to convert this column in multiple ones with pandas but I'm not able to perform the…
dadokkio
  • 41
  • 1
  • 3
2
votes
1 answer

Increment the value of a node in the json after converting the xml to json structure

I have an xml of the current format. I convert this xml to a json using the xmltodict library in python.
Laura Smith
  • 293
  • 3
  • 13
2
votes
1 answer

Python 3: Unable to convert XML to dict using xmltodict

I am trying to convert data from an XML file to python dict, but am unable to do so. Following is the code I'm writing. import xmltodict input_xml = 'data.xml' # This is the source file with open(input_xml, encoding='utf-8', errors='ignore') as…
Kushagra
  • 626
  • 6
  • 20
2
votes
1 answer

Can I "force_list" more than one parameter in xmltodict?

I am calling a web API in Python, getting data back in XML, converting the response into a dictionary using xmltodict, but for several elements, sometimes I get a dictionary (single element) and sometimes I get a list (multiple elements) in…
Phileas
  • 41
  • 4
2
votes
1 answer

Python : How to navigate XML sub-nodes efficiently?

I am trying to extract certain data points from XML and have tried two options... Working with XML format using ElementTree Working with Dictionary using xmltodict Here's what I have got so far, Code # Packages #…
WeShall
  • 409
  • 7
  • 20
2
votes
0 answers

nested ordered dict iteration failing

readers note: this data is initially obtained from XML -- if there is an easier way to get xml directly into mysql database please let me know -- been searching a lot and have not quite found that. I am attempting to do a for loop through an…
username
  • 55
  • 5
2
votes
0 answers

Python - Compare Large XML Files

Python - 2.7.3 I want to compare two xml files (Size approx. - 100 MB) I updated code based on discussion on this thread. Comparing two xml files in python I used element.iter() instead of GetChildren(). For testing purposes, I edited the xml file…
Jay
  • 339
  • 1
  • 7
  • 23
2
votes
4 answers

Remove special characters from keys of a parsed xml file using xmltodict

I have parsed an xml file using the xmltodict module and the result is stored in a dictionary of dictionaries. Now I want to remove the special characters @ and # in every key of the dictionary. def remove_using_json(parse_result): data = {} …
Snehal K
  • 21
  • 1
  • 4
2
votes
1 answer

Python import XML intro SQLITE (xmltodict)

I'm trying to parse an XML file and import it into an SQLITE database. the XML looks like this: unit name 00032749
Faryus
  • 161
  • 1
  • 4
  • 14