Return an XML as a String

Discussion in 'XML' started by Maximiliano Barone, Nov 21, 2003.

  1. I would like to return an XML with all its tags in a String (I am
    developing with Java).
    I have built the Document in a DOM an then I want to convert it into a
    String.

    public String MyWebService (String parameter)
    {}

    Thanks in advance.

    MDB
     
    Maximiliano Barone, Nov 21, 2003
    #1
    1. Advertising

  2. Maximiliano Barone wrote:
    > I would like to return an XML with all its tags in a String (I am
    > developing with Java).
    > I have built the Document in a DOM an then I want to convert it into a
    > String.


    This is called serialization. If you use Xerces, you can use Xerces'
    serialization classes.

    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
     
    Johannes Koch, Nov 24, 2003
    #2
    1. Advertising

  3. Maximiliano Barone

    GIMME Guest

    You can use JDOM to do it ...

    Use the DOMBuilder class to turn the DOM tree to a JDOM tree.

    Then use JDOM's XMLOutputter class (with the "" indent option
    to create the XML as a string) and the method outputString method
    to write the XML.

    IMO, if you are using Java and DOM, you'd gain a lot by
    just using JDOM and passing on DOM.
     
    GIMME, Nov 24, 2003
    #3
    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. Greenhorn
    Replies:
    15
    Views:
    881
    Keith Thompson
    Mar 6, 2005
  2. Kee Nethery
    Replies:
    12
    Views:
    2,192
    Stefan Behnel
    Jun 27, 2009
  3. DotNetGruven

    Web Services return string: An XML string

    DotNetGruven, Jun 28, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    707
    DotNetGruven
    Jun 30, 2004
  4. Xeno Campanoli
    Replies:
    0
    Views:
    246
    Xeno Campanoli
    Feb 13, 2006
  5. Erik Wasser
    Replies:
    5
    Views:
    517
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page