我有一些类似这样的 XML:
<topics>
<topic id="50"/>
<topic id="51"/>
<topic id="52"/>
</topics>
<discussions>
<discussion type="foo">talked about T50 as Discussion 1000</discussion>
<discussion type="bar">Food is yummy!</discussion>
<discussion type="foo">talked about T52 as Discussion 1050</discussion>
</discussions>
鉴于特定主题 ID ($topicID
),我想要做以下事情:
创建XPath表达式,如果包含文本
T$topicID as Discussion <corresponding-discussion-id>
的<discussion>
具有type="foo"
则返回真。设计一个XPath表达式,该表达式将提取文本
Discussion <对应的讨论ID>
,假设$topicID
是已知的。
这是可能的吗?
Update:
关于第一个,我正在考虑需要类似于:
exists(
//discussions/discussion[
@type="foo" and
contains(text(), concat($topicId, ??? )) <-- What goes here? I think we need
] some kind of matches(...) around the
) concat(), too.