Xquery以斜体<i> </i>查找所有单词

时间:2013-04-26 01:05:34

标签: xml xquery

我正在尝试编写一个XQuery,它将返回italics()中所有单词的列表,用于xml,如:

<p>There is abundant evidence of a widened and deepened interest in <i>modern</i>
 science. How could it be <i>otherwise</i> when we <i>think</i> of the magnitude and the
 eventfulness of recent advances?</p>

谢谢!

1 个答案:

答案 0 :(得分:0)

let $p := 
<p>There is abundant evidence of a widened and deepened interest in 
<i>modern</i> science. How could it be <i>otherwise</i> when we <i>think</i> of the
magnitude and the eventfulness of recent advances?</p>
return $p/i

如果您将嵌套在元素中的斜体,则可以使用$p//i搜索所有后代。如果您需要一系列字符串而不是<i>元素,则可以使用:

for $i in $p/i
return string($i)

或者某些XQuery处理器将支持更简洁的$p/i/string()