11.07.2015 Views

Leer y escribir datos XML - Willy .Net

Leer y escribir datos XML - Willy .Net

Leer y escribir datos XML - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Leer</strong> y <strong>escribir</strong> <strong>datos</strong> <strong>XML</strong> 15El siguiente código es un ejemplo de cómo <strong>escribir</strong> un DataSet:Visual Basic .NETC#Get<strong>XML</strong>Visual Basic .NETC#Dim ds As New DataSet()Dim da As New SqlDataAdapter( _"select * from Authors", conn)da.Fill(ds)ds.WriteXml(Server.MapPath("filename.xml"))DataSet ds = new DataSet();SqlDataAdapter da = new SqlDataAdapter("select * from Authors", conn);da.Fill(ds);ds.WriteXml(Server.MapPath("filename.xml"));La representación <strong>XML</strong> del DataSet puede <strong>escribir</strong>se en un archivo, un flujo,un XmlWriter o una cadena. Estas opciones proporcionan una gran flexibilidadpara el modo de transporte de la representación <strong>XML</strong> del DataSet. Para obtenerla representación <strong>XML</strong> del DataSet como una cadena, utilizaríamos el métodoGetXml, como muestran los siguientes ejemplos de código:Dim strXmlDS As String = ds.GetXml()string strXmlDS = ds.GetXml();GetXml devuelve la representación <strong>XML</strong> del DataSet sin información deesquema. Para <strong>escribir</strong> la información de esquema desde el DataSet (como elesquema <strong>XML</strong>) a una cadena, utilizamos GetXmlSchema.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!