Pregunta
I execute a procedure and fill the values in a DataSet
. Procedure returns XML datatype values. When I convert the DataSet
to XML, I get the XML datatype values as string but I want it as child nodes. How do I do this?
Procedure Outputs:
I convert DataSet
to XML as below
DataSet ds = null;
using (SqlConnection connection = new SqlConnection(sConnectionString))
{
connection.Open();
SqlCommand Sqlcommand = new SqlCommand();
Sqlcommand.CommandType = CommandType.StoredProcedure;
if (SqlParamlist != null)
{
foreach (SqlParameter Sqlparameter in SqlParamlist)
{
Sqlcommand.Parameters.AddWithValue(Sqlparameter.ParameterName, Sqlparameter.Value);
}
}
Sqlcommand.CommandText = sProc;
Sqlcommand.Connection = connection;
sProcParams = sProc + " " + sProcParams;
using (SqlDataAdapter da = new SqlDataAdapter(Sqlcommand))
{
ds = new DataSet("DATATABLE");
da.Fill(ds, "DATAROW");
Sqlcommand.Parameters.Clear();
da.Dispose();
}
connection.Close();
}
XmlDataDocument xDoc = new XmlDataDocument();
xDoc.LoadXml(ds.GetXml());
Here's what my xDoc.OuterXml
has
<DATATABLE>
<DATAROW>
<xmllimes><row><time>16:00:00</time></row></xmllimes>
</DATAROW>
<DATAROW>
<xmllimes><row><time>14:20:00</time></row></xmllimes>
</DATAROW>
<DATAROW>
<xmllimes><row><time>12:30:00</time></row></xmllimes>
</DATAROW>
</DATATABLE>
but I want ds.GetXML()
to return the following
<DATATABLE>
<DATAROW>
<xmllimes>
<row>
<time>16:00:00</time>
</row>
</xmllimes>
</DATAROW>
<DATAROW>
<xmllimes>
<row>
<time>14:20:00</time>
</row>
</xmllimes>
</DATAROW>
<DATAROW>
<xmllimes>
<row>
<time>12:30:00</time>
</row>
</xmllimes>
</DATAROW>
</DATATABLE>
No hay solución correcta
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow