XML

G

Guest

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?
 
H

Hans Kesting

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top