|
Subject:
|
Reading XML file using ASP
|
|
Posted By:
|
itHighway
|
Post Date:
|
4/28/2006 1:53:14 PM
|
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
|
|
Reply By:
|
tclancy
|
Reply Date:
|
4/28/2006 2:43:52 PM
|
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.
|
|
Reply By:
|
itHighway
|
Reply Date:
|
4/29/2006 4:52:57 AM
|
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>
|