1

「このイベントについて:」というテキストを含む子<strong>要素を持つ<p>要素の後に<p>要素を取得するxpath式を作成するにはどうすればよいですか。

つまり、どのパス式で「<p>」要素が得られ、<P>の後に「Hello」テキストが続き、その下に<Strong>テキストがあります…</ p>

<p>
    <strong>About this event:</strong>
    …
</p>
<p>Hello</p>

?-

4

3 に答える 3

2
//p[strong[.='About this event:']]/following-sibling::p

また

//p[strong[.='About this event:']]/following-sibling::p[.='Hello']
于 2012-05-01T17:08:33.843 に答える
1

これを試して:

//p[normalize-space(strong)='About this event:']/following-sibling::p

p次を追加して、これを最初に絞り込むこともできます[1]

//p[normalize-space(strong)='About this event:']/following-sibling::p[1]
于 2012-05-01T17:04:16.870 に答える
0

これはできるはずだと思います。Perl のxpathツールからの出力は次のとおりです。

so zacharyyoung$ xpath so.xml '//p[strong = "About this event:"]/following-sibling::p[1]'
Found 1 nodes:
-- NODE --
<p>Hello</p>

XPath は//p[strong = "About this event:"]/following-sibling::p[1]

于 2012-05-01T17:08:33.670 に答える