简体   繁体   中英

Sitecore Query returns null when using attributes

We have a sitecore support ticket open for this issue, but I hope I could get someone else that's experienced this issue also.

Here is the output from my immediate window while debugging my sitecore 6.6 instance:

?db.SelectSingleItem("/sitecore/content/Www/Data/Recruiting/Metadata/Companies/00000001/*[@@name='0000001873']")
null
?db.SelectSingleItem("/sitecore/content/Www/Data/Recruiting/Metadata/Companies/00000001/*")
0000001873 (en#1@web), id: {1848E256-E7C2-4BFC-9AF7-72EE14E37C82}
Database: "web"
Id: "{1848E256-E7C2-4BFC-9AF7-72EE14E37C82}"
Language: "en"
Name: "0000001873"
Version: "1"

Basically when I run either SelectSingleItem or GetItem and include any attribute (@@id or @@name), I get null returned. However, if I remove the filtering attribute I do get a result set. Notice that the result set I get without the filter, is the first item in the list, is also the item I'm searching for with the @@name attribute.

I get this result ONLY in code. Using xPath designer I get a result.

I encountered a similar issue and it ended up being a folder whose name started with the number zero. I chalked it up as a potential issue with the way Sitecore parses queries and didn't look into it much further. Try escaping the folder name like so:

/sitecore/content/Www/Data/Recruiting/Metadata/Companies/#00000001#/*[@@name='0000001873']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM