XML

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

    XML

    I want to build an xml document and let my web service return it. Its real
    simple xml. Whats the best way of doing this? xmldocument? xmltextwriter?
    Should i return the document itself or convert it to a string?
  • Hans Kesting

    #2
    Re: XML

    I want to build an xml document and let my web service return it. Its real
    simple xml. Whats the best way of doing this? xmldocument? xmltextwriter?
    Should i return the document itself or convert it to a string?
    It depends on what you want to do (as always):
    - XmlDocument provides random-access to the XML tree, so you can read
    back (and use) what you have written, while changing somewhere else.
    - XmlTextWriter doesn't give you access to the XML tree but has some
    handy methods to create a file (or string) in XML format. As such it
    should be much leaner than XmlDocument.

    As for what you should return: I have found that when you return an
    XmlDocument from your webservice, the receiving proxy returns an
    XmlNode. It is possible to import this into a new XmlDocument.

    The transferred number of characters might be a bit smaller for
    XmlDocument, as that is transfered as a part of the SOAP XML while a
    returned string will get encoded (">" becomes ">" and so on) first.
    But with the rest of the processing involved, I don't think this
    difference in size should be a deciding factor.

    Hans Kesting


    Comment

    Working...