Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 28th, 2006, 02:08 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 198
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via MSN to itHighway
Default Reading XML file using ASP

Hello,

Using ASP I need to read a xml file and save the values in variables. The data in XML file is in following format:


 <CLIENT adSource="MSN" age="14">
  <PERSON SSN="00000345" lastName="Blood" firstName="Anderson" DOB="4/3/62" />
     <EMPLOYER name="The itHighway" position="clerk" payDays="">
       <PHONE type="Work" number="603-921-0677" />
       <PHONE type="Boss" number="603-924-0067" />
     </EMPLOYER>
 </CLIENT>

 
Old May 1st, 2006, 06:21 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use code similar to the following to load the file into a DOMDocument

    dim oXml
    set oXml = Server.CreateObject("MSXML.DOMDocument")

    oXml.load server.mappath("..\Whatever.asp")

Once you have the document, you can access the various elements and attributes using the XPath queries. (I am assuming you have a root element that encloses the rest of your xml)

    Set oNode = oXml.selectSingleNode("//CLIENT/EMPLOYER")
    response.write oNode.Attributes.getNamedItem("name").Text

I hope this helps you get started...

Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with PHP file reading XML file for output rydog65 Beginning PHP 0 March 26th, 2008 05:13 PM
reading a XML file connect2sandep XML 1 December 14th, 2006 04:50 AM
reading a XML file connect2sandep General .NET 0 December 13th, 2006 02:10 PM
Reading XML file using ASP itHighway Classic ASP XML 1 June 7th, 2006 06:16 AM
Reading XML file using ASP itHighway XSLT 2 April 29th, 2006 04:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.