Jump to content

Parsing Xml Include Using Python


Nihilists
 Share

Recommended Posts

Trying to get xinclude to work with Python using the example from:http://msdn.microsof...y/aa302291.aspx footer.xml

<?xml version="1.0"?><footer>© Contoso Corp, 2003</footer>

page.xml

 <?xml version="1.0"?><webpage><body>Hello world!</body>   <xi:include href="footer.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/></webpage>

Python Code Executed

from xml.dom.minidom import *xml = 'page'dom = parse("%s\%s.xml" % (path, xml))print dom.toprettyxml(indent=" ")

Results

<?xml version="1.0" ?> <webpage><body>Hello world!</body><xi:include href="footer.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/></webpage>

What I am hoping to get:

<?xml version="1.0"?><webpage><body>Hello world!</body>   <footer xml:base="templates/footer.xml">© Contoso Corp, 2003</footer></webpage>

Essentially, I want to "import" XML data into another XML and have it parsed using Python. I would prefer to not have to install another module... however would do so if needed. Thanks in advance.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...