开发者

XPath and special characters

I am having an issue with an XPath query I'm performing for a Sitecore CMS system.

This query works fine:

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

But when I try this:

/root/content/Meta-Data/Tips/*[@SomeAttribute='someke开发者_如何学运维y']

I get an error which says "End of string expected at position 22" which is where the dash character is found. I was under the impression that the dash was not a special character in XML... am I doing something wrong here? Do I need to encode this in some way? Or is this a bug in the XPath parser? Any suggested workarounds?


Change this:

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

To this:

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


According to the XML spec for characters in tag names, the hyphen should be a valid character. I've done a bit of XPath testing with this site and found it helpful for comparing results with other parsers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜