【发布时间】:2021-06-09 20:34:54
【问题描述】:
使用 XPath,我想在任何其他子元素之前获取那些是 item 元素的第一个子元素的 cmets。
我有这样的 XML:
<list>
...
<item id="52">
<!-- this is optional comment, need get this -->
<randomParam>asd</randomParam> <!-- not this comment -->
<anotherRandomParam type="3" />
<paramText /> <!-- not this comment -->
...
</item>
<item id="53">
<param1>test</param1> <!-- not need this comment -->
<param2 title="text">text</param2>
<someParam>
<!-- not need this comment -->
<test />
<test />
<test />
</someParam>
...
</item>
...
</list>
【问题讨论】: