public static void SetChecked(this IXPathNavigable navigable, bool value)
{
var navigator = navigable.GetNavigator();
var hasAttribute = navigator.MoveToAttribute("checked", string.Empty);
if (hasAttribute == value)
{
// No change is required
return;
}
if (value)
{
// Set the attribute
navigator.SetAttribute(string.Empty, "checked", string.Empty, "checked");
}
else
{
// Remove the checked attribute if it exists
navigator.DeleteSelf();
}
}