gpt4 book ai didi

c# - 从 XmlElement 返回 XmlDocument

转载 作者:太空宇宙 更新时间:2023-11-03 21:50:31 25 4
gpt4 key购买 nike

我是 C# 的新手,我不确定这里是否有所有详细信息。

最初,我应该发送 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();

但是系统失败说它被保护了。

最佳答案

从外观上看,RetrieveParsedRawData 返回一个 XmlElement 而不是 xmldocument。所以这应该有效。

cred.CredExecution mycredit = new cred.CredExecution();
System.Xml.XmlElement XmlEle = mycredit.RetrieveParsedRawData(inquiry, true);
System.Xml.XmlDocument XmlDoc = XmlEle.OwnerDocument;

关于c# - 从 XmlElement 返回 XmlDocument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14781764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com