XML
  Home arrow XML arrow Extracting XML content from an XML file fr...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Extracting XML content from an XML file from within SQL Server 2000 using Managed Code
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2005-11-29

    Table of Contents:
  • Extracting XML content from an XML file from within SQL Server 2000 using Managed Code
  • Developing the .NET component
  • Deploying the .NET component
  • Testing the .NET component from within SQL Server 2000
  • Creating a stored function to call the .NET component and testing it

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Extracting XML content from an XML file from within SQL Server 2000 using Managed Code


    (Page 1 of 5 )

    This article explains how to develop a .NET based component, which can extract XML content from an XML file and return the same to SQL Server 2000 with the help of T-SQL (Transact-SQL).
    There are two downloadable files available for this article. You can find them here and here.

    The sample downloadable solutions (zip) were entirely developed using Visual Studio.NET 2003 Enterprise Architect on Windows Server 2003 Standard Edition.  But, I am confident that it would work with other versions of Windows (which support .NET 1.1) versions as well.

    To help you understand this article, I suggest you refer to my previous contribution “Developing Managed Code and executing it from within Microsoft SQL Server 2000.”

    The problem and the solution

    Microsoft SQL Server 2000 already supports XML.  The XML support has been greatly enhanced with the help of “Configuring IIS to support SQL Server XML.”  You can already find several articles on www.aspfree.com to help you work with Microsoft SQL Server 2000 and XML.

    The most important issue to understand is that Microsoft SQL Server 2000 (unlike Microsoft SQL Server 2005) does not natively support XML.  The simplest example of this is that it does not have any “XML related data type” (but Microsoft SQL Server 2005 does).  We need to still use the “Varchar” data type to hold XML data in the table.

    As long as storage is concerned, it may not be a big issue.  We can create a simple column of type “Varchar” data type and place it in XML (as if it is a huge string).  Inserting or modifying XML content with the “Varchar” data type is very simple and does not need much overhead.  But what if I need to upload an XML file into a column of type “Varchar”?  This would be an issue.  SQL Server 2000 natively will not be able to access any file system.

    Microsoft really thought about this scenario (and of course, several others too) and developed a special SDK to work with XML along with SQL Server 2000.  The extension is called SQLXML.  It is really a great extension to SQL Server 2000, which gives all sorts of possibilities for integrating XML directly into the SQL Server 2000.  But, just to upload an XML file into a field (or column), it is completely unnecessary to work with SQLXML unless you have other issues tied to that.

    Finally, I needed to develop my own component to read an external XML file and return the content to SQL Server 2000 with a simple stored function.  And to my amazement, it worked fine and I was very successful.  How did I develop it?

    As usual, we develop our managed code (.NET code) using a “class library” project, sign it “strongly” and push it into GAC (Global Access Cache).  As Microsoft SQL Server 2000 doesn’t know anything about GAC, we need to register it as a COM component also (using “RegAsm” Utility).  Once all of the above steps are completed, we need to create a stored function to access the component using some of the built-in “extended stored procedures.”

    Now, let us stop telling stories and implement the concept.

    More XML Articles
    More By Jagadish Chaterjee


       · Hello, did you ever work with Managed code with SQL Server 2000 (together with...
     

    XML ARTICLES

    - Path, Predicates, and XQuery
    - Using Predicates with XQuery
    - Navigating Input Documents Using Paths
    - XML Basics
    - Introduction to XPath
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE
    - UI Design with Java and XML Toolkits
    - Displaying ADO Retrieved Data with XML Islan...
    - Widget Walkthrough
    - Introduction to Widgets
    - The Why and How of XML Data Islands
    - Creating an XUL App Installer
    - Overlays in XUL
    - Skinning Your Custom XUL Applications


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway