private static bool CheckAttributePosition(XmlAttribute attribute, out XmlAttributeCollection attributes, int index) {
XmlElement element = attribute.OwnerElement;
if (element != null) {
attributes = element.Attributes;
if (index >= 0
&& index < attributes.Count
&& attribute == attributes[index]) {
return true;
}
}
else {
attributes = null;
}
return false;
}