I have some XML that is stored in the database and passed in as a string to my method.
I run the following expression in an online XPath tester:
/settings/ReportOptions/ReportWidget/widget[@Name='Output Method']/Properties/Visibility/VisibilitySetting[@Name]
and I get the following results:
But when I run the following code:
var customizationApplied = false;
var firstProperty = Items[0];
var settings = firstProperty.Widget.Report.Settings;
var widgetName = firstProperty.Widget.Name;
// Select the node and place the results in an iterator
var strExpression = settings.Compile("/settings/ReportOptions/ReportWidget/widget[@Name='Output Method']/Properties/Visibility/VisibilitySetting[@Name]");
var nodeIterator = settings.Select(strExpression);
// iterate through the results
while (nodeIterator.MoveNext())
{
var xmlPropertyName = nodeIterator.Current.GetAttribute("Name", string.Empty);
var propertyToCustomize = (from prop in Items
where string.Equals(prop.Name, xmlPropertyName, StringComparison.OrdinalIgnoreCase)
select prop).FirstOrDefault();
if (propertyToCustomize != null)
{
var xmlPropertyValue = nodeIterator.Current.GetAttribute("Value", string.Empty);
propertyToCustomize.IsEnabled = StringToObjectHelper.GetValue(xmlPropertyValue, false);
customizationApplied = true;
}
}
I get no results. The nodeIterator always shows this on the mouseover:
Position=0, Current={Root}
and when I execute the nodeIterator.MoveNext() method, it returns false.
Can anyone please shed some light on what the problem could be? It all worked before and nothing has been changed.
Thanks,
Lee
VulpesPosted Feb 26, 2014, 5:50 AM