Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.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
C# 从XPathNodeIterator获取数据_C#_Asp.net_Xml_Xslt - Fatal编程技术网

C# 从XPathNodeIterator获取数据

C# 从XPathNodeIterator获取数据,c#,asp.net,xml,xslt,C#,Asp.net,Xml,Xslt,我有一个XPathNodeIterator xpProducts,它包含这样的XML <estocklevel>0</estocklevel> <weightingram>0</weightingram> <unit></unit> <volume>0</volume> <discountgroup></discountgroup> <manufactor>3186

我有一个XPathNodeIterator xpProducts,它包含这样的XML

<estocklevel>0</estocklevel>
<weightingram>0</weightingram>
<unit></unit>
<volume>0</volume>
<discountgroup></discountgroup>
<manufactor>31862244</manufactor>
<deliverydate>1900-01-01T00:00:00</deliverydate>
<dayscreated extra="dayscreated">41489</dayscreated>
 string  strProductID = xpProducts.Current.Select("/manufactor");
但它抛出了一个错误

Error   3   Cannot implicitly convert type 'System.Xml.XPath.XPathNodeIterator' to 'string' D:\Projects\20-06-2013-Files\App_Code\DataFetcher.cs    55  28  D:\Projects\20-06-2013-Files\

无法从XPathNodeIterator获取字符串数据吗?

要获取字符串数据,您需要一个XPathNavigator:

string strProductID = null;
XPathNavigator navProductID = xpProducts.Current.SelectSingleNode("manufactor");
if(navProductID != null)
{
  strProductID = navProductID.Value;
}
我还建议使用
foreach
循环,而不是
MoveNext()
Current