Print XML documents:HELP

Discussion in 'Java' started by Chris Peppas, Jan 29, 2004.

  1. Chris Peppas

    Chris Peppas Guest

    > How can I print this xml (with JDOM using Xpath or any other
    > methods) without its tags.
    >
    > <?xml version='1.0' encoding='ISO-8859-1'?>
    > <words>
    > <word id="word_1">Annotation</word>
    > <word id="word_2">tool</word>
    > <word id="word_3">in</word>
    > <word id="word_4">Java</word>
    > <word id="word_5">.</word>
    > </words>
    >
    > I would like to get in a string the sentence that will look like this:
    >
    > Annotation tool in Java.
    > Thank you
    Chris Peppas, Jan 29, 2004
    #1
    1. Advertising

  2. Chris Peppas

    BarryNL Guest

    Chris Peppas wrote:
    >>How can I print this xml (with JDOM using Xpath or any other
    >>methods) without its tags.
    >>
    >><?xml version='1.0' encoding='ISO-8859-1'?>
    >><words>
    >> <word id="word_1">Annotation</word>
    >> <word id="word_2">tool</word>
    >> <word id="word_3">in</word>
    >> <word id="word_4">Java</word>
    >> <word id="word_5">.</word>
    >></words>
    >>
    >>I would like to get in a string the sentence that will look like this:
    >>
    >>Annotation tool in Java.
    >>Thank you


    How about this XSLT?

    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:eek:utput method="text"/>
    <xsl:template match="words">
    <xsl:for-each select="word">
    <xsl:value-of select="concat(.,' ')"/>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

    Just use the Xalan libraries from Apache to run it.
    BarryNL, Jan 30, 2004
    #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. Syntext, Inc
    Replies:
    0
    Views:
    426
    Syntext, Inc
    Nov 15, 2004
  2. Replies:
    2
    Views:
    427
    TextDoctor
    May 7, 2005
  3. Replies:
    1
    Views:
    477
    Juan T. Llibre
    Oct 18, 2006
  4. keto
    Replies:
    0
    Views:
    925
  5. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    346
    David Cournapeau
    Dec 30, 2008
Loading...

Share This Page