1

I have simple XML document:

<?xml version="1.0" encoding="utf-8" ?> <root xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <date>BBB</date> <name>CCC</name> </root> 

I need to select name value "CCC", by date value "BBB".It works fine for next XPATH:

/root[date=BBB]/name

But as long as i have namespace declared i can not upper XPATH. For this case i know it is possible to use local-name() function. But if i write next expression

/*[local-name() = 'root[date=BBB]']/*/*[local-name() = 'name']

It does not work.

1 Answer 1

1

Replacing any QName test for *[local-name()='...'] in

/root[date='BBB']/name 

You should use:

/*[local-name() = 'root'][*[local-name()='date']='BBB'] /*[local-name() = 'name'] 

But for this case I would use:

/*[*[local-name()='date']='BBB']/*[local-name() = 'name'] 

A little shorter with a "whatever root element".

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.