我正在尝试使用 xml 节点读取属性。但我无法读取它。我正在做某事,但我无法弄清楚。我的 xml 文件看起来像这样..
我正在尝试读取 InterfaceRequestID 和 InterfaceName,这是我的代码..
if (fPortalGuid != string.Empty)
{
HttpWebRequest request = WebRequest.Create("http://cramapp-dt-02s.cable.comcast.com:8158/restfulqueryservice/queryservice/getrequestdetails?api_key=hiding key&request_id=33ebc6e9-9def-4f39-adf9-bba2edef3b54") as HttpWebRequest;
request.Method = "POST";
using (Stream stm = request.GetRequestStream())
{
using (StreamWriter stmw = new StreamWriter(stm))
{
stmw.Write(soap);
}
}
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Console application output
string result = reader.ReadToEnd();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(result);
XmlNodeList radiusdns_nodelist;
XmlNodeList request_nodelist;
XmlNodeList fqdn_nodelist;
radiusdns_nodelist = xmlDoc.SelectNodes("/RADIUSDNSQueryResponsePayload");
request_nodelist = xmlDoc.SelectNodes("/RADIUSDNSQueryResponsePayload/request");
fqdn_nodelist = xmlDoc.SelectNodes("/RADIUSDNSQueryResponsePayload/request/fqdn");
string strInterfaceID = string.Empty, strInterfaceName = string.Empty;
if (radiusdns_nodelist.Count > 0)
{
foreach (XmlNode main_node in radiusdns_nodelist[0].ChildNodes)
{
strInterfaceID = main_node.Attributes["InterfaceRequestID"].Value;
strInterfaceName = main_node.Attributes["InterfaceName"].Value;
}
}
}
}
我无法获得属性。我做错了什么?