When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search

Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs

















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs
Print this page.

Windows Systems Administrator
Jupitermedia
US-CT-Darien

Justtechjobs.com Post A Job | Post A Resume

Published: Thursday, October 12, 2000

Accessing XML Data using ASP
By Bipin Joshi


XML Information
To learn more about XML be sure to check out the 4Guys XML Article Index! It contains a number of links to great XML articles and tuturials around the Web!

- continued -

This article covers the variety of ways that XML data can be accessed from an ASP page. Before we delve into these, let's look at some of the various ways XML data can be stored. Some of these storage methods include:

  • Simple XML-formatted text files stored in file system
  • Data stored in RDBMS that you want to convert to and from XML only when processing the database information
  • XML data built dynamically in memory during processing.

We will consider the following cases with code samples of each:

  • Accessing stand alone XML files - You can access and manipulate XML files already presented on the server
  • Creating XML files from ground up in memory - You can create entire XML document in memory and then manipulate it.
  • Sending XML data to client - Once done you can send the result of your processing to the client as XML document or XML Data Islands
  • Storing XML data - The data send by client in the form of HTML forms or XML can be processed and stored at server end in the form of XML files. The data can also be saved in Response object directly (which is then send back to the client).

Document Object Model
Document Object Model or DOM plays an important role in accessing XML data. DOM is governed by W3C and hence is a standard for accessing XML documents. DOM views XML document as a tree of nodes. Each node of the tree can be accessed randomly. The main advantage of DOM is that it provides all the functionality in an Object based way which make it very easy to use. Microsoft has created XML parser based on DOM known as MSXML. We will be using this component to access the XML documents. For working with examples presented in tis article you must have Internet Explorer 5+ installed on your machine(this automatically installs MSXML.dll on the machine). It is assumed that you are familier with XML DOM objects and how to use them via some scripting language.

Accessing stand alone XML files
Your XML data can be stored in separate disk files. In this case we need to perform following steps:

  • Create an object instance of the Microsoft.XMLDOM object
  • Set the async property of document object
  • Load the XML file
  • Check for any errors
  • Manipulate the XML file

    Let's look at a code example!

    Step 1: Create object of Microsoft.XMLDOM
    Dim mydoc
    Set mydoc=Server.CreateObject("Microsoft.XMLDOM")

    Step 2: Set async property
    If you set this property to false then DOM will prevent access to the document while it is in process of change or update. If you set this property to true then you need to use onreadystatechange event and check the readyState property for complete(4).
    mydoc.async=false

    Step 3: Load XML file
    mydoc.load("file_path")

    Note: With IIS 5.0 you can also load XML data directly from ASP Request object if it is being send from client as follows :

    ' Load the specified XML file
    mydoc.load(Request)

    Step 4: Check for any errors
    Here, you check the errorcode property and decide the success or failure of the operation.

    if mydoc.parseError.errorcode<>0 then
      'error handling code
    else
      ' proceed
    end if
    

    Now,you can use various XMLDOM methods and properties to manipulate the document.

    In Part 2 we'll look at the three other ways to access XML data through an ASP page...

  • Read Part 2!


    Windows Internet Technology | ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article



  • JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

    Solutions
    Whitepapers and eBooks
    Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
    Avaya Article: How to Feed Data into the Avaya Event Processor
    Microsoft Article: Install What You Need with Win Server ‘08
    HP eBook: Putting the Green into IT
    Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
    Avaya Article: Setting Up a SIP A/S Development Environment
    IBM Article: How Cool Is Your Data Center?
    Microsoft Article: Managing Virtual Machines with Microsoft System Center
    HP eBook: Storage Networking , Part 1
    Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
    MORE WHITEPAPERS, EBOOKS, AND ARTICLES
    Webcasts
    Intel Video: Are Multi-core Processors Here to Stay?
    On-Demand Webcast: Five Virtualization Trends to Watch
    HP Video: Page Cost Calculator
    Intel Video: APIs for Parallel Programming
    HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
    Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
    MORE WEBCASTS, PODCASTS, AND VIDEOS
    Downloads and eKits
    Sun Download: Solaris 8 Migration Assistant
    Sybase Download: SQL Anywhere Developer Edition
    Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
    Red Gate Download: SQL Compare Pro 6
    Iron Speed Designer Application Generator
    MORE DOWNLOADS, EKITS, AND FREE TRIALS
    Tutorials and Demos
    How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
    eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
    IBM Article: Collaborating in the High-Performance Workplace
    HP Demo: StorageWorks EVA4400
    Microsoft How-to Article: Get Going with Silverlight and Windows Live
    MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES