WebServices C# VWD 2008

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!
 
G

Gregory A. Beamer

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.
 

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

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,116
Latest member
LeanneD317
Top