Which method will return all nodes of an XDocument?

Which method will return all nodes of an XDocument?

Which method will return all nodes of an XDocument?

A.
doc.DescendantNodes();

B.
doc.Descendants();

C.
doc.Root.Allnodes();

D.
doc.GetAllnodes();

Explanation:
public IEnumerable<XNode> DescendantNodes() Returns a collection of the descendant nodes for this document or element, in document order.
public IEnumerable<XElement> Descendants() Returns a collection of the descendant elements for this document or element, in document order.



Leave a Reply 2

Your email address will not be published. Required fields are marked *


John Galt

John Galt

Descendants returns only descendant elements, while DescendantNodes returns all types of nodes (elements, attributes, text nodes, comments, etc)