Stephane Rolland
Stephane Rolland

Reputation: 39896

I have some difficulties in understanding this XPATH expression/syntax

here is the xpath used for selecting nodes.

document.SelectNodes("my/node/url/@*[name(.)!='name_excluded']");

I can understand the @* and the !=' ' But I can not grasp the [name(.) some predicate ]

I haven't found reference for (.) at XPath (w3 org)

Upvotes: 1

Views: 55

Answers (2)

AakashM
AakashM

Reputation: 63340

. in the predicate refers to the current node (it's an AbbreviatedStep)

name() is a function that takes a node-set (here, we pass it the context node) and returns its name

So the missing parts of your understanding are: we're going to return any attribute (@*) SUCH THAT the attribute's name is not name_excluded.

Upvotes: 2

Fred Foo
Fred Foo

Reputation: 363487

@* selects all the attributes of all the url nodes. name(.) is then, for each of those attributes, its name, so this selects all attributes of url nodes except for the name_excluded attributes.

Upvotes: 1

Related Questions