I realize that SOAP webservices in .NET return XML representation of whatever object the web method returns, but if I want to return data formatting in XML what is the best object to store it in?
I am using the answer to this question to write my XML, here is the code:
XmlWriter writer = XmlWriter.Create(pathToOutput);
writer.WriteStartDocument();
writer.WriteStartElement("People");
writer.WriteStartElement("Person");
writer.WriteAttributeString("Name", "Nick");
writer.WriteEndElement();
writer.WriteStartElement("Person");
writer.WriteStartAttribute("Name");
writer.WriteValue("Nick");
writer.WriteEndAttribute();
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
Now I can return this output as a String to my calling webmethod, but it shows up as <string> XML HERE </string>
, is there anyway to just return the full xml?
Please in your answer, give an example of how to use said object with either XmlWriter or another internal object (if you consider XmlWriter to be a poor choice). The System.Xml package (namespace) has many objects, but I haven't been able to uncover decent documentation on how to use the objects together, or what to use for what situations.