Convert Dataset to ordinary XML

xiaoxiao2021-03-06  60

Everyone knows that using the WebService passed by Dataset, Microsoft will add Schema at each node, so it cannot be compatible with J2EE, Flash, so I found a way to convert them into ordinary XML.

Code is as follows: Method a: Public Class DataSetToXML: Inherits System.Web.UI.Page Private Sub Page_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim objConn As SqlConnection Dim strSql As String strSql = "SELECT TOP 10 * FROM Customers" objConn = New SqlConnection (ConfigurationSettings.AppSettings ( "ConnectionString")) Dim sdaCust As New SqlDataAdapter (strSql, objConn) Dim dstCust As New DataSet () sdaCust.Fill (dstCust, "Customers") ' Save data to xml file and schema file dstCust.WriteXML (Server.MapPath ( "Customers.xml"), XmlWriteMode.IgnoreSchema) dstCust.WriteXMLSchema (Server.MapPath ( "Customers.xsd")) End Sub this method is written an xml file method two: _ Public Function ListAllRooms () As XmlDocument Try m_CpCourseArrange.FillRoomId (m_DsCourseArrange) 'Dim reader As New MemoryStream Dim doc As New XmlDocument doc.LoadXml (m_DsCourseArrange .Getxml.toString) Return doc Catch ex As Protocols.SoapException Throw SoapExceptionE.RaiseException ( "ListAllRooms", "http://tempuri.org/CourseArrange", ex.Message, "4000", ex.Source, SoapExceptionE.FaultCode.Server) End Try End FunctionGetXML -. Returns the XML representation of the data stored in the DataSet (MSDN) Private Shared Sub DemonstrateGetXml () 'Create a DataSet with one table containing two columns and 10 rows Dim ds As DataSet = New DataSet ( "myDataSet"). DIM T as datatable = ds.tables.add ("items") T.COLUMNS.ADD ("id", type.gettype)

转载请注明原文地址:https://www.9cbs.com/read-83675.html

New Post(0)