0

For the below path in XPath, I need to have a condition for parser, where the value of the attribute is '1'

./*[local-name()='AccountNumber']/@UndocumentedAccount

I've tried a few things so far, but none seem to work

./*[local-name()='AccountNumber']/@UndocumentedAccount='1'

./*[local-name()='AccountNumber'][@UndocumentedAccount='1']

./*[local-name()='AccountNumber']/@*[UndocumentedAccount and text()='1']

I know how to build such conditions for the value of the element itself, but haven't figured out yet how to do the same for the attribute values

1 Answer 1

1

If you are trying to select the UndocumentedAccount attribute only if its value is 1, then the syntax you are probably looking for is:

./*[local-name()='AccountNumber']/@UndocumentedAccount[.='1']

The dot is shorthand for the self axis which is the context item (the item immediately to the left of the [ bracket). You can also try the following to only select AccountNumber nodes having an UndocumentedAccount attribute = 1:

./*[local-name()='AccountNumber' and @UndocumentedAccount ='1']/@UndocumentedAccount
Sign up to request clarification or add additional context in comments.

1 Comment

The first option did not work for some reason, but the second one works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.