Which code segment should you inser at the empty line?

The application contains following XML document.
<feed>
<title>Products</title>
<entry>
<title>Entry title 1</title>
<author>Author 1</author>
<content>
<properties>
<description>some description</description>
<notes>some notes</notes>

<comments>some comments</comments>
</properties>
</content>
</entry>

</feed>
You plan to add localizationfeatures to the application.
You add the following code segment:
public IEnumerable <XNode> GetTextNodesForLocalization(XDocument doc)
{
— empty line here
return from n in nodes
where n.NodeType = XmlNodeType.Text
select n;
}
You need to ensure that the GetTextNodeForLocalization method returns all the XML text nodes of
the XML document. Which code segment should you inser at the empty line?

The application contains following XML document.
<feed>
<title>Products</title>
<entry>
<title>Entry title 1</title>
<author>Author 1</author>
<content>
<properties>
<description>some description</description>
<notes>some notes</notes>

<comments>some comments</comments>
</properties>
</content>
</entry>

</feed>
You plan to add localizationfeatures to the application.
You add the following code segment:
public IEnumerable <XNode> GetTextNodesForLocalization(XDocument doc)
{
— empty line here
return from n in nodes
where n.NodeType = XmlNodeType.Text
select n;
}
You need to ensure that the GetTextNodeForLocalization method returns all the XML text nodes of
the XML document. Which code segment should you inser at the empty line?

A.
IEnumerable <XNode> nodes = doc.Descendants;

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

C.
IEnumerable <XNode> nodes = doc.DescendantNodes;

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 *