I have some XML like this:
<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>
Given a particular topic ID ($topicID
), I would like to do the following:
Devise an XPath expression which is true if there is a
<discussion>
withtype="foo"
that contains the textT$topicID as Discussion <corresponding-discussion-id>
.Devise an XPath expression which, given that
$topicID
, will extract the textDiscussion <corresponding-discussion-id>
.
Is this possible?
Update:
For the first one, I'm thinking I need something like:
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.