I'm trying to understand the difference between the extension method, DescendantsnNodes and the method, "Nodes" of the class XDocument.
I can see that the DescendantsNodes should return all descendants of this document or element and Nodes should return all child nodes of this document or element.
I don't understand what's the difference between "all child nodes" and "all descendants".
could someone please clarify this?
A child node would be a node which is directly "underneath" a certain node (parent). A descendant would be a node which is "underneath" the same node, but it could also be a number of levels "underneath" the child node.
A child node will be a descendant, but a descendant won't always be a child node.
It might be easier to visualise with a small code sample:
Produces: