#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    XML to Json convert


    Hello everyone,

    i have a question toJson conversion. I am parsing a huge XML file with lxml and i pass it to a variable. After that i would like to convert that object that .parse create to Json.

    from lxml import etree

    inFile = 'file:///home/vasgen/Projects/hackathon/docs/samples/PriceXplorer_XTRSearch_4MB.xml'

    xmlData = etree.parse(inFile)

    I tryied with jsonlib but with no result.
    Does anyone know how to export xmlData var to Json??

    I want to add that i am tottaly new to Python.

    Thanks in advance
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2010
    Posts
    7
    Rep Power
    0
    Best I could find without resorting to writing my own parser:

    xmltojson

    If I was going to write my own though I would use:

    xmltodict

    in case I needed to adjust any of the data in between processes and then serialise to json using the json module.

    Hope this helps.
    Last edited by zilog6502; January 4th, 2013 at 12:04 PM. Reason: Found additional method

IMN logo majestic logo threadwatch logo seochat tools logo