public static XmlElement FindChildWithClass(XmlElement parent, string classVal)
{
// Can probably be done with xpath ./*[contains(concat(" ", normalize-space(@class), " "), " classVal ")]
// (plus something to get the first one).
// But I'm more confident of this version and suspect it might be faster for such a simple case.
foreach(var node in parent.ChildNodes)
{
var elt = node as XmlElement;
if(elt == null)
continue;
var eltClass = " " + GetAttributeValue(elt, "class") + " ";
if(eltClass.Contains(" " + classVal + " "))
return elt;
}
return null;
}