Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
<item id=1> <name>item1</name> <price>30</price> </item> <item id=2> <name>item2</name> </item>
.net の価格がないアイテムのみを選択するには、xpath が必要です。
元の質問の場合:
item[price]
要素の子itemを持つすべての要素を提供します。priceこれには空が含まれる<price/>ので、一致を避けたい場合
item
price
<price/>
<item> <name>item3</name> <price></price> </item>
次に、次のいずれかが必要です
item[price/text()] item[normalize-space(price)]
逆に、をitem持たない要素のみを選択するにはprice、次を使用できます。
item[not(price)]