Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bulk import to SQL Server using SQLXML
Message
From
28/04/2005 23:05:53
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
28/04/2005 04:46:55
General information
Forum:
ASP.NET
Category:
XML
Environment versions
OS:
Windows Server 2003
Database:
MS SQL Server
Miscellaneous
Thread ID:
01009131
Message ID:
01009532
Views:
12
Danijel,

Your best bet is to use an XSL stylesheet to get rid of the data tags. Removing a set of tags is a very straightforward deal with XSL. The VS help files give an example of removing HTML tags from a web page that can be converted into removing your data tags.

>(originally posted in SQL forum, but in case some XML experts don't find it there)
>
>Hi there
>
>I'm trying to bulk load a ton of data into the db using SQLXML 3.0. My problem can best be described using an example from SQLXML help:
>
>
>Create this table:
>CREATE TABLE Cust(CustomerID  int PRIMARY KEY,
>                       CompanyName varchar(20),
>                  City        varchar(20))
>GO
>
>Create a file in Notepad, and save it as SampleSchema.xml. To this file, add the following XSD schema:
>
>
><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>            xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
>
>  <xsd:element name="Customers" sql:relation="Cust" >
>   <xsd:complexType>
>     <xsd:sequence>
>       <xsd:element name="CustomerID"  type="xsd:integer" />
>       <xsd:element name="CompanyName" type="xsd:string" />
>       <xsd:element name="City"        type="xsd:string" />
>     </xsd:sequence>
>    </xsd:complexType>
>  </xsd:element>
></xsd:schema>
>
>Create a file in Notepad, and save it as SampleXMLData.xml. To this file, add the following XML document:
>
><ROOT>
>  <Customers>
>    <CustomerID>1111</CustomerID>
>    <CompanyName>Sean Chai</CompanyName>
>    <City>NY</City>
>  </Customers>
>  <Customers>
>    <CustomerID>1112</CustomerID>
>    <CompanyName>Tom Johnston</CompanyName>
>     <City>LA</City>
>  </Customers>
>  <Customers>
>    <CustomerID>1113</CustomerID>
>    <CompanyName>Institute of Art</CompanyName>
>  </Customers>
></ROOT>
>
>
>Create a file in Notepad, and save it as BLoad.vbs. To this file, add the VBScript code
>
>set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload.3.0")
>objBL.ConnectionString = "provider=SQLOLEDB;data source=localhost;database=Northwind;integrated security=SSPI"
>objBL.ErrorLogFile = "c:\error.log"
>objBL.Execute "SampleSchema.xml", "SampleXMLData.xml"
>set objBL=Nothing
>
>Modify the connection string to provide the appropriate server and database name. Execute the script file.
>
>This is working fine. Now, suppose the SampleXMLData.xml file looked like this:
>
><ROOT>
>  <Customers>
>    <CustomerID><data>1111</data></CustomerID>
>    <CompanyName><data>Sean Chai</data></CompanyName>
>    <City><data>NY</data></City>
>  </Customers>
>  <Customers>
>    <CustomerID><data>1112</data></CustomerID>
>    <CompanyName><data>Tom Johnston</data></CompanyName>
>     <City><data>LA</data></City>
>  </Customers>
>  <Customers>
>    <CustomerID><data>1113</data></CustomerID>
>    <CompanyName><data>Institute of Art</data></CompanyName>
>  </Customers>
></ROOT>
>
>
>Notice that there are "data" tags around all values. What should the SampleSchema.xml look like then is what I need to figure out. I've tried several alternatives, but none with success.
>Hope someone can shed some light on this.
>
>Thanks
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform