sax xmlreader.parse problem

Discussion in 'Java' started by curwen, Nov 10, 2003.

  1. curwen

    curwen Guest

    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
    curwen, Nov 10, 2003
    #1
    1. Advertising

  2. curwen

    Andy Fish Guest

    I reckon

    new ByteArrayInputStream(myString.getBytes(encoding))

    "curwen" <> wrote in message
    news:...
    > 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
    Andy Fish, Nov 10, 2003
    #2
    1. Advertising

  3. curwen

    Sudsy Guest

    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.
    Sudsy, Nov 10, 2003
    #3
  4. curwen

    Andy Fish Guest

    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.
    >
    Andy Fish, Nov 10, 2003
    #4
  5. curwen

    curwen Guest

    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.
    > >
    curwen, Nov 11, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    XMLReader or XMLDocument ?

    Guest, Dec 23, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    811
    Michel
    Dec 24, 2003
  2. George Durzi

    DataSet into XmlReader

    George Durzi, Dec 31, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    6,888
    Patrick Steele [MVP]
    Dec 31, 2003
  3. =?Utf-8?B?TGFMYUJveQ==?=

    XmlReader Problem

    =?Utf-8?B?TGFMYUJveQ==?=, May 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    424
    =?Utf-8?B?SmFrb2IgQ2hyaXN0ZW5zZW4=?=
    May 13, 2004
  4. Jeff Calico
    Replies:
    2
    Views:
    1,184
    Joseph Kesselman
    Feb 22, 2006
  5. Gary Robinson

    xml.sax.xmlreader and expat

    Gary Robinson, Jun 27, 2006, in forum: Python
    Replies:
    2
    Views:
    333
    Stefan Behnel
    Jun 28, 2006
Loading...

Share This Page