You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Swanson, Brion" <Br...@westgroup.com> on 2002/10/23 14:51:07 UTC

RE: What is the best way to remove XML header and serialize it to String

'<?' (paired with '?>') simply indicates an XML processing instruction and
may appear in various places throughout an XML document.  It may very well
be the case here, however, that the special 'xml' processing instruction is
the only one of its sort in the input document.

Text processing may be the fastest and easiest manner of removing the XML
header, but as you can probably guess, it introduces the possibility that
you will remove the wrong thing and create non-well-formed XML.  If you
limit the removal of processing instructions to check the first two
characters of the string, then the only allowable removable PI may be
limited to the XML header if it exists.  On the other hand, do these
documents have XML comments above the root node?  Will that play havoc with
your discovery of an XML header string?

Just some things to consider.

Good luck!

Brion Swanson

-----Original Message-----
From: Aleksandar Milanovic [mailto:amilanovic@galdosinc.com]
Sent: Tuesday, October 22, 2002 10:52 PM
To: xerces-j-user@xml.apache.org
Subject: RE: What is the best way to remove XML header and serialize it
to String


Well, if there is no header then I suppose the first thing in the string is
an element that starts with < and not <?. I am not sure though if <? can
appear in other places. You should check the XML spec.

Alex

-----Original Message-----
From: evgeniy.strokin@rocketrainer.com
[mailto:evgeniy.strokin@rocketrainer.com]
Sent: October 22, 2002 5:30 AM
To: xerces-j-user@xml.apache.org
Subject: What is the best way to remove XML header and serialize it to
String


I have XML as a String and I need only to remove an XML header <?xml
version="1.0" encoding="UTF-8"?> from this and get XML as a String back.
Of course I can cut this string by second symbol < but there is no sure I
have XML with header.
So, what is the best way to remove XML header?

Thanks
Jenya

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org