Which code segment should you insert at line 03?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application contains the following XML document.
< feed >
< title > Products < /title >
< entry >
< title > Entry title 1 < /title >
< author > Author1 < /title >
< content >
< properties >
< description > some description < /description >
< n otes > some notes < /notes >
< comments > some comments < /comments >
< /properties >
< /content >

< /entry >

< /feed >
You plan to add localization features to the application.
You add the following code segment. (Line numbers are included for reference only.)
01 public IEnumerable < XNode > GetTextNodesForLocalization(XDocument doc)
02 {
03
04 return from n in nodes
05 where n.NodeType == XmlNodeType.Text
06 select n;
0 7 }
You need to ensure that the GetTextNodesForLocalization method returns all the XML text nodes of
the document. Which code segment should you insert at line 03?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application contains the following XML document.
< feed >
< title > Products < /title >
< entry >
< title > Entry title 1 < /title >
< author > Author1 < /title >
< content >
< properties >
< description > some description < /description >
< n otes > some notes < /notes >
< comments > some comments < /comments >
< /properties >
< /content >

< /entry >

< /feed >
You plan to add localization features to the application.
You add the following code segment. (Line numbers are included for reference only.)
01 public IEnumerable < XNode > GetTextNodesForLocalization(XDocument doc)
02 {
03
04 return from n in nodes
05 where n.NodeType == XmlNodeType.Text
06 select n;
0 7 }
You need to ensure that the GetTextNodesForLocalization method returns all the XML text nodes of
the document. Which code segment should you insert at line 03?

A.
IEnumerable < XNode > nodes = doc.DescendantNodes();

B.
IEnumerable < XNode > nodes = doc.Nodes();

C.
IEnumerable < XNode > nodes = doc.Descendants();

D.
IEnumerable < XNode > nodes = doc.NodesAfterSelf();

Explanation:
DescendantNodes() Returns a collection of the descendant nodes for this document or element, in
document order.
Descendants() Returns a collection of the descendant elements for this document or element, in
document order.
Nodes() Returns a collection of the child nodes of this element or document, in document order.
NodesAfterSelf() Returns a collection of the sibling nodes after this node, in document order



Leave a Reply 0

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