0

I have an XML which is in the form of a string which my parser can't work with. Concretely it has all the XML tags but it is a string instead of an XML file. It should be first converted to an XML file. I have already googled and came across a similar question on SO but that deals with libxml2's C++ api. I am working in python.

1
  • This question appears to be off-topic because it is (a) based on the false premise that you need to write XML to a file; and (b) writing to a file is not specific to XML. Commented May 15, 2014 at 15:53

1 Answer 1

3

libxml2 can parse strings that contain xml.

import libxml2
libxml2.parseDoc('<?xml version="1.0"?> <data> <something>Baaahh!</something> </data>')

this returns a valid xml object.

If you want to read a whole file you can use libxml2.parseFile

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

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.