我得到一个当“财产‘的innerText’是只写”试图读取属性值XML属性“的innerText”是只写试图读取属性值
这里的时候,错误是我的XML:
<?xml version="1.0" encoding="utf-8"?>
<products>
<product ID="11837">
<price currency="EUR">75.29</price>
<properties>
<property name="brand">
<value></value>
</property>
</properties>
<variations/>
</product>
</products>
要提取我做的代价:它返回
node.SelectSingleNode("price").InnerText
“75.29”
但当我这样做:
node.Attributes("ID").InnerText
我得到的错误:
住宅“的innerText”是只写
我看不出有任何理由为什么它是只写的,不知道我可以改变它,以便我可以读取值。
原来它与基类有关。当我循环浏览结果时: 对于每个节点在nodeList中,我没有声明节点的类型。我注意到这一点,因为IntelliSense并不是暗示我是InnerText或Value方法。我现在在我的循环上面声明'Dim node As XmlNode'(我之前删除了它),并且它再次工作。也使用Innertext方法而不是Value方法。谢谢! – Flo 2013-05-02 13:13:46