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