About Me

My photo
Northglenn, Colorado, United States
I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).

Wednesday, September 20, 2006

MS ASP.Net Assessment Question: Extract data from XML Node.

You have an application that reads the following XML document with an instance of the XmlReader class.
<bookstore>
<books>
<book genre="'reference'" id="'23'">
<title>World Atlas</title>
<author status="bestseller">
<first-name>Joe</first-name>
<last-name>Worden</last-name>
</author>
<price>8.99</price>
</book>
</books>
</bookstore>

You advance the XmlReader to the author XmlNode.
You need to extract the values of the author XmlNode and all of its children as a string.
What should you do?

A) Use the ReadInnerXml method of the XmlReader.
B) Use the ReadOuterXml method of the XmlReader.
C) Use the ReadString method of the XmlReader.
D) Use the Value property of the XmlReader

A would be wrong since it would only get the children information.
B is correct since it would give the children tags and the current start tag.
C would return a string, but only the data up to the first end tag.
D this would only return the attribute of the author in this case.

No comments: