0
我是C#的新手,我不确定是否所有的细节都在这里。从XmlElement返回XmlDocument
最初,我应该发送一个SOAP请求并将其响应读入数据集。
下面的代码工作:
DataSet ds = new DataSet();
cred.CredExecution mycredit = new cred.CredExecution();
ds = mycredit.RetrieveParsedRawData(inquiry, true);
// I have the Web Reference "cred" added to the project.
// Since I wasn't sure if a service reference was needed, I added that too.
现在响应格式改变为XML,我不知道如何读它。
我改变了代码如下:
System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
cred.CredExecution mycredit = new cred.CredExecution();
XmlDoc = mycredit.RetrieveParsedRawData(inquiry, true);
但它失败,错误:
Cannot implicitly convert type 'System.Xml.XmlElement' to 'System.Xml.XmlDocument'
我试着使用:
System.Xml.XmlElement XmlEle = new System.Xml.XmlElement();
但系统不能说它是保护。
感谢您的答复约翰尼。 – user2055287 2013-02-08 23:11:01
当我按照你的建议更新了代码时,它没有发生错误。现在如何看到回应?当它是一个数据集时,我使用了“ds.WriteXml(filePath);”将XML写入文件。与XDoc,我没有看到任何选择WriteXML。所以我添加了“MessageBox.Show(XmlDoc.ToString());”并显示“System.Xml.XmlDocument”。从不同的工具中,我看到与 ... ... RetrieveParsedRawDataResponse> –
user2055287
2013-02-08 23:29:27
要获取xml内容,您必须在XmlElement上调用InnerText或InnerXml。 你可以在这里找到XmlElement的文档:http://msdn.microsoft.com/en-us/library/system.xml.xmlelement.innerxml.aspx – 2013-02-09 07:18:18