SAX with JAXP  
Author Message
Araxes Tharsis





PostPosted: 2004-3-5 1:43:00 Top

java-programmer, SAX with JAXP Hi,

I want to parse a XML document with SAX (using JAXP) and found lot's of
examples of parsing from a file. But... I have the XML in a String variable
and want to parse from there. All the 'parse' methods from the SAXParse
class receive a File, or a InputStream, or a URI... I don't want to create a
file just to be able to parse the XML (for performance reasons).
Any help appreciated,

Araxes Tharsis


 
nos





PostPosted: 2004-3-5 4:57:00 Top

java-programmer >> SAX with JAXP y u post >1 group?

"Araxes Tharsis" <email***@***.com> wrote in message
news:40477554$0$20707$email***@***.com...
> Hi,
>
> I want to parse a XML document with SAX (using JAXP) and found lot's of
> examples of parsing from a file. But... I have the XML in a String
variable
> and want to parse from there. All the 'parse' methods from the SAXParse
> class receive a File, or a InputStream, or a URI... I don't want to create
a
> file just to be able to parse the XML (for performance reasons).
> Any help appreciated,
>
> Araxes Tharsis
>
>


 
Araxes Tharsis





PostPosted: 2004-3-5 8:27:00 Top

java-programmer >> SAX with JAXP Just 2 groups is crossposting? Ok... I will stop publishing to these 2
groups at the same time.
Best Regards,
Araxes Tharsis


 
 
Araxes Tharsis





PostPosted: 2004-3-5 8:27:00 Top

java-programmer >> SAX with JAXP Just 2 groups is crossposting? Ok... I will stop publishing to these 2
groups at the same time.
Best Regards,
Araxes Tharsis


 
 
mgungora





PostPosted: 2004-3-5 9:58:00 Top

java-programmer >> SAX with JAXP "Araxes Tharsis" <email***@***.com> wrote in message news:<40477554$0$20707$email***@***.com>...
> Hi,
>
> I want to parse a XML document with SAX (using JAXP) and found lot's of
> examples of parsing from a file. But... I have the XML in a String variable
> and want to parse from there. All the 'parse' methods from the SAXParse
> class receive a File, or a InputStream, or a URI... I don't want to create a
> file just to be able to parse the XML (for performance reasons).
> Any help appreciated,
>
> Araxes Tharsis

Use org.xml.Parser.parse(org.xml.sax.InputSource....) method.

-murat
 
 
Sudsy





PostPosted: 2004-3-5 13:28:00 Top

java-programmer >> SAX with JAXP Araxes Tharsis wrote:
> Hi,
>
> I want to parse a XML document with SAX (using JAXP) and found lot's of
> examples of parsing from a file. But... I have the XML in a String variable
> and want to parse from there. All the 'parse' methods from the SAXParse
> class receive a File, or a InputStream, or a URI... I don't want to create a
> file just to be able to parse the XML (for performance reasons).
> Any help appreciated,
>
> Araxes Tharsis

Since this came up recently, it's apparent that you didn't check
the archives. If you dig through the javadocs (another good place
to start) then you'll find that InputSource is also accepted as
an argument to SAXParser#parse(). Further, InputSource has a
constructor which takes a Reader as the argument. Further digging
uncovers the StringReader class which extends Reader. So if you've
got a String named s, parsing is as basic as:
SAXParser.parse( new InputSource( new StringReader( s ) ),
DefaultHandler );

 
 
Thomas Schodt





PostPosted: 2004-3-5 14:34:00 Top

java-programmer >> SAX with JAXP nos wrote:
> y u post >1 group?

Araxes Tharsis wrote:
> Just 2 groups is crossposting?

By definition, yes.

> Ok... I will stop publishing to these 2
> groups at the same time.

Please note that crossposting is not by definition bad
(but multiposting is).


nos did not say; "please don't", nos asked; "why".

If you have a valid reason, that's fine.
You can always reference the FAQ
http://makeashorterlink.com/?A3C414E97
 
 
Araxes Tharsis





PostPosted: 2004-3-7 4:30:00 Top

java-programmer >> SAX with JAXP Thank you very much to all!