[jdom-interest] Extracting ProcessingInstructions

Laurent Bihanic laurent.bihanic at atosorigin.com
Fri May 3 05:27:22 PDT 2002


Hi,

As per the XML specification, the XML header <?xml ... ?> is not a "regular" 
PI. Parsers do not provide any way to access the header information and thus 
JDOM can't get it for you.

If you want to access this information, you should use your own InputStream to 
gather it while the parser is reading the XML stream.

Laurent

DELAJARTE François wrote:
> Hi!
> I'm new to JDOM and i use beta 8.
> My problem is that i would like to extract the first line of my XML 
> document (<? xml etc... ?>).
> So i use the getContent() method on my JDOM Document but i just get one 
> element representing the root element and nothing more...
> 
> Here is my piece of code :
> 
>                 java.util.List list = theDoc.getContent();
>                 java.util.ListIterator iter = list.listIterator();
>                 while (iter.hasNext())
>                 {
>                         Object obj = iter.next();
>                         if (obj instanceof org.jdom.ProcessingInstruction)
>                         {
>                                 // do things...
>                                 break;
>                         }
>                 }
> I tried to put comments and i could extract them. It's just like if the 
> parsing operation delete the only line i would like to have ... so 
> frustrating...
> 
> Hope one could help because i read Jason's response on nearly the same 
> question but... it doesn't work for me.
> 
> Francois
> 




More information about the jdom-interest mailing list