Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT 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, 01:53 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>


Any Idea..
Any Help...
Will be greatly appriciated.

Thanks!
Zeeshan Ahmed

 
Old April 28th, 2006, 02:43 PM
Authorized User
 
Join Date: Jan 2006
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This should get you started

Dim oXML, oClientNode, iClientAge
Set oXML = Createobject("MSXML2.DOMDocument.4.0")
oXML.Load(PATH_TO_FILE_ON_DISK)
Set oClientNode = oXML.selectSingleNode("//CLIENT")
iClientAge = oClientNode.getAttribute("age")
Set oXML = Nothing

Create an XML object, load your document, select a node with an XPath query, get an attribute from it.

 
Old April 29th, 2006, 04:52 AM
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

Thanks tclancy. It worked.

How should I implement the loop if there are multiple records

Example:


<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>
<CLIENT adSource="Yahoo" age="24">
  <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>







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 Classic ASP Basics 1 May 1st, 2006 06:21 PM





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