我将一个XML字符串作为 Web 服务发送,我想解释它。我的 XML 字符串是这样的:
<?xml version="1.0" encoding="utf-8"?>
<result is_array="true">
<item>
<candidate_offer_id>175</candidate_offer_id><contact_person>Ranjeet Singh</contact_person><offer_status>8</offer_status>
</item>
<item><candidate_offer_id>176</candidate_offer_id><contact_person>Ranjeet Singh</contact_person><offer_status>8</offer_status>
</item>
</result>
在这个 XML 字符串中,我想访问列表中节点 <item> 下的子节点(如候选者_offer_id、offer_status 名称),以便稍后我可以运行循环以在循环中获取所有这些值并将其放在 Excel 工作表上。到现在为止我是这样写的:
WebResponse response = request.GetResponse();
Stream responseStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(responseStream);
string responseFromServer = reader.ReadToEnd();
StringBuilder output = new StringBuilder();
var str = XElement.Parse(responseFromServer);
var result = str.Element("item");
但是我如何解释var
结果以获取列表中父节点 <item> 的标签名称以及如何解释它?