上記のxmlサンプルでは、xpathを使用して、クラスfooに属し、クラスバーにないすべての書籍を選択したいと考えています。先頭と末尾のスペースで@class
値をパディングすることによってXpathで複数のクラスを持つ要素を選択するにはどうすればよいですか?
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book class="foo">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book class="foo bar">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book class="foo bar">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
良い質問、1。最初のものが特に最適化されていないXPath 2.0エンジンを使用した場合、最も効率的な2つの異なるXPath 2.0ソリューションについては、私の答えをご覧ください。 –