1
votes

The XPath builder is available from the Sitecore 'developer center'. Start > Developer Center > Tools > XPath Builder. I'm using sitecore query notation.

I would like to search for media items over a certain filesize -

/sitecore/media library//*[@size > 99999]

This does a string compare on the size, so the 'greater than' doesn't work as expected.

/sitecore/media library//*[Number(@size) > 99999]

This works as expected, but trips up when it encounters an item with no filesize - for example folders. I've tried a few permutations to filter out these items without success. How can I fix this?

1

1 Answers

2
votes

There may be something cleaner, but this works:

/sitecore/media library//*[@size!='']/.[Number(@size) > 99999]

Note that the line below does not work, since and in XPATH does not have the "short-circuit" functionality that && has in C#.

/sitecore/media library//*[@size!='' and Number(@size) > 99999]