Wolfpack'08
Wolfpack'08

Reputation: 4128

Find a node that does not contain an attribute?

The creator of an XML document that I'm running XQuery commands on left the lang attribute out of titles in titled sales materials (books, records, CD's, etc.) that are in English, making it difficult to locate English titles. I'm looking for a way to locate results that do not contain an xml:lang attribute.

Upvotes: 1

Views: 903

Answers (2)

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243449

Use just:

//title[not(@xml:lang)]

Upvotes: 3

Wolfpack'08
Wolfpack'08

Reputation: 4128

Add a where clause containing the not() function, to limit your results:

for $resulta in doc("test")//catalog/item/title
where $resulta[not(@xml:lang)] (: this line :)
return $resulta

Upvotes: -1

Related Questions