Return an XML as a String

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maximiliano Barone

    #1

    Return an XML as a String

    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

  • Johannes Koch

    #2
    Re: Return an XML as a String

    Maximiliano Barone wrote:[color=blue]
    > 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.[/color]

    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.)

    Comment

    • GIMME

      #3
      Re: Return an XML as a String

      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.

      Comment

      Working...