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" <> wrote in message
news: 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" <> wrote in message
news:...
> 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" <> wrote in message news:<vKPrb.1110$>...
> 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" <> wrote in message
> news:...
> > 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
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57