public static void VisitNodes(XContainer source, XNodeVisitor func, int depth) { func(source, depth); foreach (XNode child in source.Nodes()) { if (child is XElement) { VisitNodes(child as XContainer, func, depth + 1); } else { func(child, depth + 1); } } }
public static void VisitNodes(this XContainer source, XNodeVisitor func) { VisitNodes(source, func, 0); }