1

So I have an XML string that I want to convert to JSON in Python 3.2. I was going to do that by converting the string to a python object via lxml and then convert the object to JSON via JSONEncoder.

Unfortunately, lxml does not seem to be built for Win32, does anyone have any suggestions for an alternate XML - Python library or XML - JSON library?

8
  • users.skynet.be/sbi/libxml-python Commented May 28, 2011 at 21:14
  • im using python 3.2 - the latest one there is for python 2.7 Commented May 28, 2011 at 21:18
  • Is it lxml the Python package or libxml the C library that you can't find builds for? I see a bunch for the former from pypi.python.org/pypi/lxml/2.3 Commented May 28, 2011 at 21:24
  • ...and for the latter from zlatkovic.com/libxml.en.html. I'm not sure how the versions match, but there are plenty of other Google hits. Commented May 28, 2011 at 21:26
  • the installers on pypi.python.org/pypi/lxml/2.3 do not detect that I have Python installed because they couldn't find it in the registry. Anyone know what reg keys they are looking for? Commented May 28, 2011 at 21:46

2 Answers 2

1

xml.etree.ElementTree and its faster sibling xml.etree.cElementTree are included with all Python versions from 2.5 onwards. The Python 3.2 docs are here.

lxml.etree is an implementation of the ElementTree interface with some enhancements and (well-documented) minor differences. However the structure of an Element instance is the same. Is there any particular reason why you must have lxml?

Sign up to request clarification or add additional context in comments.

Comments

1

I have a super simple script that does this:

XML to Python data structure « Python recipes « ActiveState Code http://code.activestate.com/recipes/534109-xml-to-python-data-structure/

It is mainly for people to reference XML data as an object in Python. For your purpose, you can introspect the node's content in DataNode._attrs and .data.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.