![]() ![]() If you are familiar with Python language, you can try to use the "xmltodict" module The output XML document is good, only if input XML document contains well structured data. This section provides a tutorial example on how to use a 'xmltodict' conversion module to perform JSON-to-XML conversions in a Python script. ∟JSON-to-XML Conversion Module for Python I feel stupid :PĮDIT: Although that would work, it is very extensive compared to other methods.XML Tutorials - Herong's Tutorial Examples I thought he was just using the json library and didnt finish reading it. Oh my, I just reread his code an realised he was using json2xml. Return "\n".join(result_list) # <- this one was misindented Result_list.append(json2xml(sub_obj, "\t" + Line_spacing)) Result_list.append("%s" % (Line_spacing, tag_name)) Result_list.append(json2xml(sub_elem, Line_spacing)) With that corrected it might work reasonably well. ![]() (Mar-10-2017, 09:36 PM)zivoni Wrote: Your json2xml function has wrong indentation on line 19 - return is inside for loop, so processing ends after parsing first member in dictionary. MAKE A NEW SCRIPT USING THAT CODE REPLACING 'examples/example.json' with the location of your. Python -m src.cli -file="examples/example.json"^Voodoo magic B (Allows you to use json2xml via cmd) OR:ĭata = omjsonfile('examples/example.json').dataĭata_object.json2xml() #xml output ^Voodoo magic C (json2xml via a script)ĭo not try to implement this into your current script as it probally will not work. Pip3 install json2xml^Voodoo magic A (Installs json2xml via PIP3) ![]() Thanks! Please completely scrap what I said before. ![]() I Imported the json2xml and now all of json2xml saying re declared json2xml above with no usage? can you update my code with what you are mentioning? so I can run it here and see? (Mar-10-2017, 07:53 PM)pasi12 Wrote: Thanks for the tips I was able to install with pip but i am not sure where to put/link the python code in my code as you mentioned? what a bout a print statement?ĭata = omjsonfile('examples/example.json').dataĭata_object = Json2xml(data) data_object.json2xml() ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |