WebServices C# VWD 2008

  • Thread starter Thread starter Paulo
  • Start date Start date
P

Paulo

How do I put the content returned from a WebService (XMLNode) into a
XmlDocument to save it as a .xml?

exportapedido ExpPedido = new exportapedido(); //WebService
XmlDocument XMLdoc = new XmlDocument();
try
{
XmlNode node1 = ExpPedido.ExportaPedido(719); //Calling webservice wich
returnes XMLNode
XMLdoc.ImportNode(node1, true);
XMLdoc.Save("test.xml"); //ERROR: This an invalid XML document. The
document does not have a root element.
catch (Exception err)
{
Response.Write("<script> alert('" + err.Message.Replace("'", "") +
"')</script>");
}

How to fix it: "ERROR: This an invalid XML document. The document does not
have a root element."

Thanks!
 
This is an "it depends" kind of answer.

If you merely want the node and its contents, then save using a StreamReader
and avoid XML altogether.

If you want to save as a valid XML file, add the root node and then append
the node and contents to the root node.

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think Outside the Box! |
********************************************
 
Back
Top