A document that has well formed tags is an XML document but it is not a *valid* XML document. To be valid it must have a DTD.
> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Mike Hommey > Sent: Thursday, 26 July 2007 3:44 PM > To: Stefan Jeglinski > Cc: [email protected] > Subject: Re: [xml] Remove First Two Header Nodes from Xml Doc > > > On Wed, Jul 25, 2007 at 10:18:27PM -0400, Stefan Jeglinski > <[EMAIL PROTECTED]> wrote: > > >Now what I wanted to do is to remove the first two tags of the xml > > >document which are hightlighted below. i.e. > > ><?xml version=" 1.0" encoding="utf-8"?> > > ><!DOCTYPE RequestMessage SYSTEM "RequestMessage.dtd"> > > > > > >So what changes are required in the above mentioned code > to generate > > >the xml document which would be like. > > > > Not possible? At the risk of saying something wrong since I've only > > been using libxml a couple months, removing those 2 lines > would make > > the file not xml, so the question falls outside the scope > of the API. > > If you really want to do it, you could just write custom C code to > > remove them, but in that case, you should just write custom > C code to > > create your desired output to begin with. > > > > I'll gladly consider corrections to my assertion. > > An xml document without doctype is still an xml document, and > it's still > possible to remove it with the C API: > > xmlDtdPtr dtd = xmlGetIntSubset(doc); > if (dtd != NULL) { > xmlUnlinkNode((xmlNodePtr)dtd); > xmlFreeDtd(dtd); > } > > (Stolen from xmllint.c) > > The only way I know to remove the xml declaration would be to dump the > root node of the document instead of dumping the document. > > Mike > _______________________________________________ > xml mailing list, project page http://xmlsoft.org/ > [email protected] > http://mail.gnome.org/mailman/listinfo/xml > _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
