sorry still jsut feeling that out! but yes it would be great if they could fix that.. having a pile of exceptions being thrown isn't really a result you'd expect!
I am using razor to learn it but in this instance I thought it'd be cleaner to get the results of the query in a single line of code rather than the approach shown but if that's how it needs to be done! that's how it needs to be done!
XPath Returns no nodes error
Is there a way to get razor to not blow up and instead just let you proceed??
i.e.
var collectionsWithProducts = Model.XPath("./productRelease [count(./product) > 0]");
and then check for something??
i also tried returning a count like so:
var collectionsWithProductsCount = Model.XPath("count(./productRelease [count(./product) > 0])");
dynamic activeCollection = null;
if(collectionsWithProductsCount > 0)
{
activeCollection = Model.XPath("./productRelease [count(./product) > 0]").FirstOrDefault();
}
if(activeCollection != null)
{
but alas
Don't use XPath selectors would be my answer.. but yeah, this should probably be filed as a bug in codeplex.
For now you could either just use XSLT (why use Razor when all you're doing is XPath selections?) or do something like this in Razor:
A great answer thank you..
sorry still jsut feeling that out! but yes it would be great if they could fix that.. having a pile of exceptions being thrown isn't really a result you'd expect!
I am using razor to learn it but in this instance I thought it'd be cleaner to get the results of the query in a single line of code rather than the approach shown but if that's how it needs to be done! that's how it needs to be done!
Cheers,
Tom
is working on a reply...