Questions tagged [dicttoxml]

12 questions
6
votes
5 answers

Converting a dict to XML with attributes

I am using dicttoxml in python for converting dict to XML . I need to convert the dict to XML attributes. For example: dict [ { "@name":"Ravi", "@age":21, "college":"Anna University" } ] Output…
devanathan
  • 603
  • 2
  • 8
  • 34
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
  • 31
  • 2
1
vote
1 answer

dicttoxml throws AttributeError

I try to check how dicttoxml is working. But I receive this error from within the dicttoxml module. I am starting program from geany. Can anybody help? Thanks! import dicttoxml myDict = {'myKey':"theirValue"}; xml…
martinus
  • 11
  • 1
0
votes
0 answers

Convert from json to xml without ordering the data in python?

Anyone know how to convert from json to xml but keeping the data in the same order (without ordering them). I tried Json2xml, dicttoxml and dict2xml but all of them are ordering the data. Please I need help, thank you! For example: from dict2xml…
HElooo
  • 13
  • 3
0
votes
0 answers

unable to convert back to xml from output of xmltodict

I'm importing xml file into dict and further converting that dict into Json. data_dict = xmltodict.parse(xmlstr,dict_constructor=dict) json_data = json.dumps(data_dict) I've an application to make changes to the JSON file and import that json file…
0
votes
1 answer

A better XML Parser for Python 3 with nested classes (dicttoxml)

This is really part 2 to this question: A better XML Serializer for Python 3 In that question, I didn't specify that I might have the classes nested. The picklers and marshallers didn't produce the XML I was looking for. import sys from dicttoxml…
NealWalters
  • 14,090
  • 34
  • 109
  • 199
0
votes
1 answer

xmltodict and back again; attributes get their own tag

I'm trying to create something that imports an XML, compares some of the values to values from another XML or values in an Oracle Database, and then write it back again with some values changed. I've tried simply importing the xml and then exporting…
Ronald
  • 172
  • 1
  • 10
0
votes
0 answers

How can I avoid dicttoxml producing underscore in keys

I am using dicttoxml to write a dictionary structure to an xml file. For example from dicttoxml import dicttoxml myDict= {"This is a key": "some value"} myRecord= dicttoxml(myDict, attr_type=False, root=False) When checking the output file 'This is…
MaryT
  • 33
  • 4
0
votes
0 answers

Merge dicttoxml json dumps to one xml file

I have some code that takes an input.xml file from server commands and I get the output.xml Bu I need to check two servers and have a loop at end for this and I check it but I get only the last result inside output.xml file. I would need to merge…
0
votes
1 answer

dicttoxml with number as key

from dicttoxml import dicttoxml ArrayWithDigitKey={2:"vale"} xml =dicttoxml(ArrayWithDigitKey) I get this error : Traceback (most recent call last): File "", line 1, in File…
Kiro
  • 15
  • 2
0
votes
3 answers

Convert Json to XML properly

I have following dictionary structure [{ "Body" : [{ "Universal Lift Support" : ["1\"-9\" Extended Length", "10\"-14.5\" Extended Length", "15\"-19\" Extended…
SpanishBoy
  • 1,797
  • 4
  • 21
  • 43
-2
votes
2 answers

Customizing dictionary conversion with dicttoxml?

I want to convert dictionary to xml in python, I am using dicttoxml for that. My code looks like this: >>> import os >>> filepath=os.path.normpath('C:\\Users\\\\Desktop\\abc\\bc.txt') >>> with open(filepath,'r') as f: ... for line in f: ... …
sultan
  • 115
  • 2
  • 11