【发布时间】:2014-05-04 00:47:29
【问题描述】:
我正在尝试使用以下 XPath 表达式:
nodeList = root.SelectNodes("/moviedb/movie[genres="Thriller"]");
nodeList = root.SelectNodes("/moviedb/movie[contains(genres, "+ ElementValue +")]");
其中 ElementValue 是用户输入值
对于第一行,我得到如下错误:
错误 4 ) 预期
错误 6 无效的表达式术语 ')'
而第二个表达式返回 0
在我在 c# 中使用此表达式之前,我确实在网上对其进行了测试,并且它们有效。 我的 xml 看起来像这样:
<moviedb>
<movie>
<imdbid>tt2226321</imdbid>
<genres>Thriller</genres>
<languages>English</languages>
<country>USA</country>
<rating>8</rating>
<runtime>155</runtime>
<title>The Dark Knight</title>
<year>2014</year>
</movie>
<movie>
<imdbid>tt1959490</imdbid>
<genres>Action,Adventure,Drama</genres>
<languages>English</languages>
<country>USA</country>
<rating>6.5</rating>
<runtime>138</runtime>
<title>Noah</title>
<year>2014</year>
</movie>
</moviedb>
谢谢
【问题讨论】:
-
印刷错误:字符串常量内的双引号前缺少
'\'。在深入研究带有引号的 XPath 之前,您可能需要阅读有关字符串常量的信息。