1

I want to select the first attribute in my XML document that has the name "valgfase"

I have tried the following expressions:

string strExpression = "//@valgfase[1]"; 

and

string = //@valgfase[position() = 1] 

When i execute my expression, it returns ALL elements that have the attribute "valgfase".

What is the right way to do this?

I am using C# with XPathDocument and XPathNavigator

1 Answer 1

2

You should do (//@valgfase)[1].

You can see the explanation in the answer to that question.

Sign up to request clarification or add additional context in comments.

1 Comment

I just want the attribute and it's value. Thanks. I edited the question, but will still accept your answer!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.