[lxml-dev] Round Trip w/ Processing Instructions (Newbie)
Greg Willden
gregwillden at gmail.com
Wed Aug 8 21:30:50 CEST 2007
Hello all,
I love the etree stuff and I'm excited about the API additions that this
team is adding to make it better. Thanks for all your work. That said I'm
really new to ElementTree.
I am using lxml.etree version 1.3.3 on both Python 2.4.3 and 2.5.1.
I have a question about processing instructions and round trip file
processing.
Let's say I have a file 'test.xml' containing the following
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project SYSTEM "test.dtd">
<project><a><b/></a></project>
Then I run these commands
t1=etree.parse('test.xml')
t1.write('testout.xml', xml_declaration=True)
testout.xml looks like this:
<?xml version='1.0' encoding='ASCII'?>
<project><a><b/></a></project>
I see that t1.docinfo.doctype contains:
<!DOCTYPE project SYSTEM "test.dtd">
So why isn't the PI written to the file?
I am parsing/modifying a file for consumption by another program that
refuses to load the file without the PI.
Thanks
Greg
--
Linux. Because rebooting is for adding hardware.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/lxml-dev/attachments/20070808/f5546494/attachment.htm
More information about the lxml-dev
mailing list