Hi, nice to meet you.Let me ask you a question.
Programming with XML+XSLT
Suppose you have the following XML:
<DATA>
<F1>a</F1>
<F2>Yes>/F2>
<F3> U</F3>
<F4>E</F4>
<F5> Oh;/F5>
<F1> or </F1>
<F2>ki </F2>
<F3>Ku</F3>
<F4>Ke </F4>
<F5>here>/F5>
<F1>OK;/F1>
<F2>Sh </F2>
<F3>Su</F3>
<F4>se>/F4>
<F5> and </F5>
</DATA>
Among them, I am worried because I don't know how to write xpath to get only F3
data under F1=' or '
(in this case, or
).
Could you please let me know if anyone knows?
Thank you in advance.
If @user20662 is asking this question in the XPath 1.0 world like Windows+MSXML, @pgho's answer would be fine, but since the world is already moving up to XPath 3.0, what would XPath 2.0 be like at least?It's no use knowing that
As @sayuri pointed out, using If you use Xpath 2.0 or higher, wouldn't it be appropriate to use The result is "ku" returned as a value as follows. For your information,//F1[text()=' or ']/following-sibling::F3/text()
in XPath 2.0 will select two text nodes (tried on oXygen 18.1) so that the version of Xpath you want to use will work even if the version goes up, /folding][1][:'/folding=1]
string(/DATA/F1[string(.)eq']/following-sibling::F3[1])
?
As a way of thinking,
The connection is as follows:
//F1[text()=' or ']/following-sibling::F3/text()
© 2024 OneMinuteCode. All rights reserved.