OK. First you are just as well off using an XmlTextWriter to accomplish this. So I have modified your code below to illustrate this.
To answer your questions first: 2) myWriter.WriteStartDocument() 3) No you do not need to reference the .xsd file. Here you go. Sub getVendorOrders() Dim myReader As SqlDataReader Dim conDB As New SqlConnection(Me.conString) Dim Command As New SqlClient.SqlCommand("GetVendorOrders") Command.CommandType = CommandType.StoredProcedure Command.Connection = conDB 'Create your Parameters (I created 2) Dim vendorCode As New SqlClient.SqlParameter() vendorCode.ParameterName = "@vendorCode" vendorCode.SqlDbType = SqlDbType.NVarChar Dim marking As New SqlClient.SqlParameter() marking.ParameterName = "@marking" marking.SqlDbType = SqlDbType.Int 'Set Parameter Values vendorCode.Value = "SH" marking.Value = 1 'Add 2 Parameters Command.Parameters.Add(vendorCode) Command.Parameters.Add(marking) conDB.Open() Dim daSalesByCategory As New SqlClient.SqlDataAdapter() myReader = Command.ExecuteReader(CommandBehavior.CloseConnection) 'Write the dataset content out to disk as an XML file Try Dim myWriter As New System.Xml.XmlTextWriter(Server.MapPath("shirley.xml"), Encoding.UTF8) myWriter.Formatting = System.Xml.Formatting.Indented myWriter.WriteStartDocument() myWriter.WriteStartElement("crmcart:styles") While myReader.Read() myWriter.WriteStartElement("crmcart:style") myWriter.WriteElementString("crmcart:style-number", myReader("ProdCode")) myWriter.WriteStartElement("crmcart:colors") myWriter.WriteElementString("crmcart:color-code", myReader("Option Name")) myWriter.WriteElementString("crmcart:color-desc", myReader("Option Name")) myWriter.WriteStartElement("crmcart:sizes") myWriter.WriteStartElement("crmcart:size") myWriter.WriteElementString("crmcart:size-code", myReader("Option Value")) myWriter.WriteElementString("crmcart:qty", myReader("quantity")) myWriter.WriteEndElement() myWriter.WriteEndElement() myWriter.WriteEndElement() myWriter.WriteEndElement() End While myReader.Close() myWriter.WriteEndElement() myWriter.Flush() myWriter.Close() Catch x As Exception Response.Write(x) End Try conDB.Close() End Sub Ben Miller ----- Original Message ----- From: Ronda K To: [EMAIL PROTECTED] Sent: Wednesday, November 17, 2004 1:36 PM Subject: [AspNetAnyQuestionIsOk] 2nd Post SQL 7.0 to XML I posted this mornign and got some helpful answers but unfortunately they were only relevant if I were running SQL 2000 ... I am running SQL 7.0. So I am posting again in the hopes that I can get some advice. I am making an XML file on the fly from a SQL query. This is the first time I have done this and have a few questions. 1) Am I doing this the most efficient way or is there a better way to accomplish it? 2) How do I input the Required XML header info in such as Version Info: <?xml version="1.0" ?> 3) Do I need to reference the style sheet (..xsd file) Thanks for any help..... ~ Ronda Below is my code: Sub getVendorOrders() Dim myReader As SqlDataReader Dim conDB As New SqlConnection(Me.conString) Dim Command As New SqlClient.SqlCommand("GetVendorOrders") Command.CommandType = CommandType.StoredProcedure Command.Connection = conDB 'Create your Parameters (I created 2) Dim vendorCode As New SqlClient.SqlParameter() vendorCode.ParameterName = "@vendorCode" vendorCode.SqlDbType = SqlDbType.NVarChar Dim marking As New SqlClient.SqlParameter() marking.ParameterName = "@marking" marking.SqlDbType = SqlDbType.Int 'Set Parameter Values vendorCode.Value = "SH" marking.Value = 1 'Add 2 Parameters Command.Parameters.Add(vendorCode) Command.Parameters.Add(marking) conDB.Open() Dim daSalesByCategory As New SqlClient.SqlDataAdapter() myReader = Command.ExecuteReader(CommandBehavior.CloseConnection) 'Write the dataset content out to disk as an XML file Try Dim myWriter As New System.Xml.XmlTextWriter(Server.MapPath("shirley.xml"), Nothing) myWriter.WriteStartElement("crmcart:styles") myWriter.Formatting = System.Xml.Formatting.Indented While myReader.Read() myWriter.WriteStartElement("crmcart:style") myWriter.WriteElementString("crmcart:style-number", myReader("ProdCode")) myWriter.WriteStartElement("crmcart:colors") myWriter.WriteElementString("crmcart:color-code", myReader("Option Name")) myWriter.WriteElementString("crmcart:color-desc", myReader("Option Name")) myWriter.WriteStartElement("crmcart:sizes") myWriter.WriteStartElement("crmcart:size") myWriter.WriteElementString("crmcart:size-code", myReader("Option Value")) myWriter.WriteElementString("crmcart:qty", myReader("quantity")) myWriter.WriteEndElement() myWriter.WriteEndElement() myWriter.WriteEndElement() myWriter.WriteEndElement() End While myWriter.WriteEndElement() myWriter.Close() Catch x As Exception Response.Write(x) End Try conDB.Close() End Sub -- Ronda Pederson MVP ASP.Net Yahoo! Groups Sponsor ADVERTISEMENT Yahoo! Groups Links To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/