[lxml-dev] Fwd: Round Trip w/ Processing Instructions (Newbie)
Greg Willden
gregwillden at gmail.com
Thu Aug 9 15:37:16 CEST 2007
It looks like this message didn't go to the list.
---------- Forwarded message ----------
Hi Stefan,
On 8/9/07, Stefan Behnel <stefan_ml at behnel.de> wrote:
>
> > I see that t1.docinfo.doctype contains:
> > <!DOCTYPE project SYSTEM "test.dtd">
> >
> > So why isn't the PI written to the file?
>
> Hmm, the problem here is that libxml2 lacks a good backwards compatible
> way of
> serialising documents including things like processing instructions,
> internal
> subsets (DTDs) and doctype declarations (which you have here, it's not a
> PI).
>
> I'll look into it (once again). IIRC, we serialise PIs by now, but not
> internal subsets and doctypes. We should do that when serialising root
> nodes
> (especially ElementTree objects).
Sorry I've got my terminology mixed up. Obviously I'm not an XML expert.
Just enough to be dangerous ;-)
Thanks for looking into it. I searched the mailing list to see if this
stuff had come up before and I had seen a lot of similar questions so I'm
sorry if it's a FAQ or something.
You mention serializing root nodes. That brings up another question I had
along these lines.
Given the same XML file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project SYSTEM "test.dtd">
<project><a><b/></a></project>
If I do an etree.parse('test.xml') I get an ElementTree object but If I were
to have that same data as a string and call etree.XML() or etree.fromstring()
then all I get is an Element. That seems really odd to me. If this
question has been discussed (I'm guessing it has), I'd be happy with an
answer like "take a look at this thread for the discussion".
I guess it's probably more of an ElementTree API question/confusion than a
problem with lxml.etree though.
Thanks again for your work.
Greg
--
Linux. Because rebooting is for adding hardware.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/lxml-dev/attachments/20070809/2348c736/attachment-0001.htm
More information about the lxml-dev
mailing list