Problems with getting text from node (xalan)

Discussion in 'XML' started by Jeff, Sep 21, 2003.

  1. Jeff

    Jeff Guest

    I have a node that I'd call a text node, but the parser disagrees. At
    any rate, I'd like to get the text out of it. (It is some text with
    infrequent markup.

    I'm using Xalan and Java. getNodeValue() returns null, and
    isTextNode(n) returns false. Here is the only code I've been able to
    use to get the text out:

    ByteArrayOutputStream baotc = new ByteArrayOutputStream();
    StreamResult out = new StreamResult(new OutputStreamWriter(baotc));
    serializer.transform(new DOMSource(n), out);
    String tt = baotc.toString();

    It actually gives the text but has a jarbled(to me) footer and header.
    I'm doing something wrong of course.

    Thanks for your help.
    LNMEgo

    (btw, I did post this on the forums at sun, but didn't get a response.
    so, yes I did cross post, but that forum is pretty unresponsive.
    thanks)
     
    Jeff, Sep 21, 2003
    #1
    1. Advertising

  2. Jeff

    Jeff Guest

    I realized that it was due to another line of code that I have since
    fixed. Thanks to anyone who had tried to think of a solution.
    -LNMEgo


    (Jeff) wrote in message news:<>...
    > I have a node that I'd call a text node, but the parser disagrees. At
    > any rate, I'd like to get the text out of it. (It is some text with
    > infrequent markup.
    >
    > I'm using Xalan and Java. getNodeValue() returns null, and
    > isTextNode(n) returns false. Here is the only code I've been able to
    > use to get the text out:
    >
    > ByteArrayOutputStream baotc = new ByteArrayOutputStream();
    > StreamResult out = new StreamResult(new OutputStreamWriter(baotc));
    > serializer.transform(new DOMSource(n), out);
    > String tt = baotc.toString();
    >
    > It actually gives the text but has a jarbled(to me) footer and header.
    > I'm doing something wrong of course.
    >
    > Thanks for your help.
    > LNMEgo
    >
    > (btw, I did post this on the forums at sun, but didn't get a response.
    > so, yes I did cross post, but that forum is pretty unresponsive.
    > thanks)
     
    Jeff, Sep 22, 2003
    #2
    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. Replies:
    0
    Views:
    1,620
  2. Andy Fish
    Replies:
    0
    Views:
    539
    Andy Fish
    Jul 21, 2003
  3. Andy Fish
    Replies:
    0
    Views:
    1,211
    Andy Fish
    Jul 21, 2003
  4. cvissy
    Replies:
    0
    Views:
    629
    cvissy
    Nov 16, 2004
  5. Tjerk Wolterink
    Replies:
    2
    Views:
    1,482
    Dimitre Novatchev
    Aug 24, 2006
Loading...

Share This Page