Spot the web RSS 2.0
# Wednesday, December 24, 2008

Don't use your web methods to return strings as most programmers do, use them to return true XMLs.


instead of using this:

[WebMethod]
public string MyLameWebMethod()
{
XmlDocument dom = new XmlDocument();
// load XML Data ...
return dom.OuterXml;
}

Now when we want to read it on the client side we want the XML and then the operation is:
XML -> String -> XML


Use this:

[WebMethod]
public XmlDocument MyBetterWebMethod()
{
XmlDocument dom = new XmlDocument();
// load some XML ...
return dom;
}

Here we are skipping over the String step and using much more valid XML document.


Now you are avoiding an added level of transferring your XML document to string and then back to XML.
Wednesday, December 24, 2008 12:01:38 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [0] - Trackback
.Net | C# | XML
Navigation
Archive
<December 2008>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Guy Levin
Sign In
Statistics
Total Posts: 63
This Year: 0
This Month: 0
This Week: 0
Comments: 14
Themes
All Content © 2010, Guy Levin