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

Change dict to list in XML to JSON converted file

Here when I am converting the XML file to JSON using xmltodict for one value a dict is created while for multiple values a list of dict is created. Below I have attached my python code for XML to JSON conversion and the JSON value: xmltojson.py with…
0
votes
0 answers

Merging multiple XML files and removing duplicates in python?

I need a Python program that will merge all XML files in a folder, remove duplicate part IDs, and then output to a new XML file. I have the below code that was mostly provided to me by someone else, but I do not understand a lot of the logic. I'm…
0
votes
1 answer

how to wrap an xml tag using xmltodict python library

So this is the xml output I require: 1 I am using the xmltodict python library to…
python_help
  • 121
  • 1
  • 12
0
votes
0 answers

How can i get Xml Data in csv file i have extracted the Data but able to get output in Csv

I am getting the data from XML which I can print too but I cannot import it into CSV format (I need it to be opened as an excel file ) encode , enter output of xml file I tried the CSV library. I want to get output exported in a CSV file which…
0
votes
0 answers

xmltodict force_list for duplicated key

xml = """ """ would like to have a list enforced only under Header_C->Child_A as such: { …
jyang
  • 23
  • 4
0
votes
1 answer

Is there a package that converts xmltodict dictionaries to lxml trees?

The problem I have is this. I've started the XML creation using the dictionary structure used by xmltodict Python package so I can use the unparse method to create the XML. But I think I reached a point where xmltodict can't help me. I have actions…
0
votes
1 answer

Include namespace in xmltodict.unparse output

I use xmltodict to convert Python dictionaries to XML. I would like to include the namespaces. What I've come up with is this: xml_dict = { "http://namespace.org:workflow": {"action-list": "..."} } namespaces = {"http://namespace.org":…
0
votes
1 answer

Getting values from an XML file that has deep keys and values

I have a very large xml file produced from an application whose part of tree is as below: There are several items under 'item' from 0 to 7. These names are always named as numbers it can range from 0 to any number. Each of these items will have…
Shiva
  • 67
  • 1
  • 7
0
votes
0 answers

How to add two encoding type together as parameter while xml parsing?

One xml file has encoding type UTF-16 and another has UTF-8. After taking input of two files I want to parse it together, How to add two encoding type? tree = ET.parse(xmlFile) xml_data = tree.getroot() xmlstr = ET.tostring(xml_data,…
Nikita
  • 27
  • 1
  • 5
0
votes
1 answer

xmltodict 'UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte'

I am trying to read an XML.dump file using 'xmltodict' library with python 3 to make a dictionary from this file. The code I used is like: import xmltodict with open('file1.xml.dump') as fd: content = fd.read() doc =…
Sara
  • 419
  • 1
  • 6
  • 14
0
votes
1 answer

Python xmltodict.parse returns Exception "not well-formed (invalid token): line 6, column 15

Using the following code snippet I am not sure how to resolve the bad element/attribute. It seems to be quoted correctly and is in proper utf-8 form (I believe). But the \x07 is tripping up the xmltodict.parse Exception: not well-formed (invalid…
0
votes
2 answers

How can lists be distinguished depending on the types of their items?

I have converted some XML files with xmltodict to native Python types (so it "feel[s] like [I am] working with JSON"). The converted objects have a lot of "P" keys with values that might be one of: a list of strings a list of None and a string. a…
0
votes
1 answer

parsing invalid xml using xmltodict

I am reading a xml file and converting to df using xmltodict and pandas. This is how one of the elements in the file looks like https://whois.arin.net/rest/v1/net/NET-66-125-37-120-1 66.125.37.127
Devarshi Goswami
  • 1,035
  • 4
  • 11
  • 26
0
votes
0 answers

xmltodict(xml) returns dictionary values with backslashes

I want xmltodict.parse(XML)to return "XELTA\LMOR\CCS\CIP\CIP_3_2". Instead xmltodict to converts XML content to dictionary returns strings with double backslashes. XML_Input ="XELTA\LMOR\CCS\CIP\CIP_3_2" returns = xmltodict.parse(XML_Input) Returns…
Girish V
  • 3
  • 4
0
votes
0 answers

Python: Zeep library is returning a list instead of a zeep object

I'm using zeep to work with SOAP API, but the response returned from the service is a list and not a zeep object. I'm having to use raw_response=True so i can get the xml on the 'text' attribute and transform it to a dict using the xmltodict…
user13138572