Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何检查节点是否存在_Xml_C# 4.0 - Fatal编程技术网

Xml 如何检查节点是否存在

Xml 如何检查节点是否存在,xml,c#-4.0,Xml,C# 4.0,下面是我的代码。我在responseElement和相应的值中得到了xml的响应。我想知道如何在下面的表达式中检查firstName/contactid节点是否存在 var responseElement = XElement.Parse(putContactResponse); ObjInvoice.Contact_Id = responseElement.XPathSelectElement("//Contact/ContactID").Value; ObjInvoice.FirstName

下面是我的代码。我在responseElement和相应的值中得到了xml的响应。我想知道如何在下面的表达式中检查firstName/contactid节点是否存在

var responseElement = XElement.Parse(putContactResponse);
ObjInvoice.Contact_Id = responseElement.XPathSelectElement("//Contact/ContactID").Value;
ObjInvoice.FirstName = responseElement.XPathSelectElement("//Contact/FirstName").Value;