Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > sax xmlreader.parse problem

Reply
Thread Tools

sax xmlreader.parse problem

 
 
curwen
Guest
Posts: n/a
 
      11-10-2003
Hi all
I'm trying to use the .parse method accepting only inpustream as parameter,
but I have he xml file in a String (is quite short)

how can I do to pass a string to the xmlreader.parse method?

thanxs in avance
jc
 
Reply With Quote
 
 
 
 
Andy Fish
Guest
Posts: n/a
 
      11-10-2003
I reckon

new ByteArrayInputStream(myString.getBytes(encoding))

"curwen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hi all
> I'm trying to use the .parse method accepting only inpustream as

parameter,
> but I have he xml file in a String (is quite short)
>
> how can I do to pass a string to the xmlreader.parse method?
>
> thanxs in avance
> jc



 
Reply With Quote
 
 
 
 
Sudsy
Guest
Posts: n/a
 
      11-10-2003
curwen wrote:

> Hi all
> I'm trying to use the .parse method accepting only inpustream as parameter,
> but I have he xml file in a String (is quite short)
>
> how can I do to pass a string to the xmlreader.parse method?
>
> thanxs in avance
> jc
>


See java.io.StringReader class.

 
Reply With Quote
 
Andy Fish
Guest
Posts: n/a
 
      11-10-2003
in retrospect I concur with sudsy

your original comment that it only accepts inputStream was not quite
correct. You can also construct a sax InputSource from a reader, so a
StringReader would be the most appropriate solution.

"Sudsy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> curwen wrote:
>
> > Hi all
> > I'm trying to use the .parse method accepting only inpustream as

parameter,
> > but I have he xml file in a String (is quite short)
> >
> > how can I do to pass a string to the xmlreader.parse method?
> >
> > thanxs in avance
> > jc
> >

>
> See java.io.StringReader class.
>



 
Reply With Quote
 
curwen
Guest
Posts: n/a
 
      11-11-2003
the first answer work perfectly! I didn't try the other solution yet.

PS I'm using inputsource too:

ByteArrayInputStream in = new ByteArrayInputStream(fileXML.getBytes());
InputSource source = new InputSource(in);
r.setErrorHandler(new XMLErrorHandler());
r.parse( source );

thanks a lot,
both of you
jc

"Andy Fish" <(E-Mail Removed)> wrote in message news:<vKPrb.1110$(E-Mail Removed)>...
> in retrospect I concur with sudsy
>
> your original comment that it only accepts inputStream was not quite
> correct. You can also construct a sax InputSource from a reader, so a
> StringReader would be the most appropriate solution.
>
> "Sudsy" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > curwen wrote:
> >
> > > Hi all
> > > I'm trying to use the .parse method accepting only inpustream as

> parameter,
> > > but I have he xml file in a String (is quite short)
> > >
> > > how can I do to pass a string to the xmlreader.parse method?
> > >
> > > thanxs in avance
> > > jc
> > >

> >
> > See java.io.StringReader class.
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SAX decoding problem Frank Cornelis Java 1 05-15-2004 10:25 AM
Problem with characters() method in java SAX DefaultHandler Wes Batson Java 1 02-07-2004 06:51 AM
Encoding problem with SAX parser Martin Schlatter Java 2 12-14-2003 10:33 AM
Java SAX Performance Problem Christian Neuroth Java 3 08-08-2003 02:50 PM



Advertisments