Jump to content

Parsing Xml Include Using Python


Nihilists

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...