这是我的XML的一部分:使用XPath和VTD-XML获得子节点和元素的文本字符串
<MAIN>
<L>
<D>string1 string2 <b>string3</b> string4</D>
</L>
<L>
<D>string5 string6 <b>string7</b> string8 <i>string9</i></D>
</L>
</MAIN>
I want to get the content of all the <D> tags as string. So, the example above should return:
1st iteration: 'string1 string2 <b>string3</b> string4'
2nd iteration: 'string5 string6 <b>string7</b> string8 <i>string9</i>'
etc...
在VTD-XML的我用了一个自动驾驶仪的XPath“//大号/ D“和”// L/D/text()“,但没有奏效。
任何意见或替代方法将不胜感激。
问候
难道你不能只使用// L将返回一个节点列表。然后,对于那些节点循环直接的孩子,并调用任何方法返回文本。 – gshauger 2011-05-14 20:15:22
好问题,+1。查看我的答案,获取完整而简短的XPath表达式解决方案。 – 2011-05-15 16:46:50