找不到XML属性

时间:2014-07-15 10:55:55

标签: c# xml null

我正在滚动浏览我的XML并点击了RoadBlock。我的问题是我有一个产品的XML文档,它有几个功能。所以我以这种方式遍历这些特征。

 XmlNodeList nodelist = XMLdoc.SelectNodes("//ProductFeature");
    foreach (XmlNode singlenode in nodelist)
    {
       Presentation_Value = singlenode.Attributes["Presentation_Value"].InnerText;
    }

现在单个节点的所有节点都有这个XML,除了一个节点。

  <ProductFeature Localized="0" ID="149991561" Local_ID="0" Value="8 - 80" CategoryFeature_ID="12224" CategoryFeatureGroup_ID="2698" No="100033" Presentation_Value="8 - 80%" Translated="0" Mandatory="0" Searchable="0">

最后一个节点有这个XML

<ProductFeature Localized="0" ID="149812647" Local_ID="0" Value="abc.biz" CategoryFeature_ID="33538" CategoryFeatureGroup_ID="10889" No="0" Translated="1" Mandatory="0" Searchable="0">

由于Last节点没有属性&#34; Presentation_Value&#34;我在下面看到了臭名昭着的错误

  

对象引用未设置为对象的实例。

我该如何解决这个问题?

0 个答案:

没有答案