XPath and special characters

I am having a problem with the XPath request that I am executing for the Sitecore CMS system.

This request works fine:

/ root / content / Meta-Data / Tips / *

But when I try this:

/ root / content / Meta-Data / Tips / * [@SomeAttribute = 'somekey']

I get the error "End of line expected at position 22" where the dash symbol is. I got the impression that the dash was not a special character in XML ... am I doing something wrong here? Do I need to somehow encode this? Or is this an error in the XPath parser? Any suggested workarounds?

+4
source share
2 answers

Change this:

/root/content/Meta-Data/Tips/*[@SomeAttribute='somekey'] 

For this:

 /root/content/#Meta-Data#/Tips/*[@SomeAttribute='somekey'] 
+12
source

According to the XML specification for characters in tag names, a hyphen must be a valid character. I ran several XPath tests from this site and found it useful to compare results with other parsers.

0
source

Source: https://habr.com/ru/post/1307825/


All Articles