Your company receives product information from manufacturers in the form of XML documents. The product information is stored in a Microsoft SQL Server database.
The format of each XML document varies. Each one is located in a MemoryStream object named newProds.
You create a merge procedure that reads data and schema information in a DataSet object and merges the information into your database. You now need to write code to transfer the XML document and its schema into a DataSet object.
Which code segment should you use?
A.
DataSet products = new DataSet(“prodInfo”);
XmlTextReader reader = new XmlTextReader(newProds);
XmlValidatingReader validReader = new XmlValidatingReader(reader); while (validReader.Read()) {
products.WriteXml(validReader.Value);
}
B.
DataSet products = new DataSet(“prodInfo”);
products.ReadXml(newProds);
C.
DataSet products = new DataSet(“prodInfo”);
XmlDataDocument document =
new XmlDataDocument(products);
document.DataSet.ReadXmlSchema(newProds);
D.
DataSet products = new DataSet(“prodInfo”);
string myXmlData =
Encoding.UTF8.GetString(newProds.ToArray());
SqlDataAdapter adapter =
new SqlDataAdapter(“LoadSchemaType=XML”,myXmlData);
adapter.Fill(products);