Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to capture an attribute XML???

Status
Not open for further replies.

Saviour

Programmer
Feb 6, 2001
7
VE
Hi, I need to capture the value of an attribute in the XML file.

For example, the XML file contains:

<?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; standalone=&quot;yes&quot; ?>
<Clients>
<Client>
<ClientId>P9990000000041</ClientId>
<Speciality Speciality=&quot;1&quot;>Computer science</Speciality>
<MaritalSta MaritalSta=&quot;2&quot;>Single</MaritalSta>
<AprobDate />
<BirthDate>1960-01-01</BirthDate>
...
</Client>
</Clients>


I need to capture the value &quot;1&quot; of the &quot;Speciality&quot; attribute.
Which is the best way to do it?

Some part of my ASP source code is:

Dim oXMLdoc
Dim AtriXML

Set oXMLdoc = Server.CreateObject(&quot;Microsoft.XMLDOM&quot;)
oXMLdoc.async = False
oXMLdoc.Load(Server.MapPath(&quot;Files/ClientData.xml&quot;))
Set currNode = oXMLdoc.documentElement

For i = 0 To currNode.childNodes.length - 1
If currNode.hasChildNodes Then
For j = 0 To currNode.childNodes.Item(i).childNodes.length - 1
Response.Write(currNode.childNodes.Item(i).childNodes.Item(j).nodeName &amp; &quot;: &quot;)
Response.Write(currNode.childNodes.Item(i).childNodes.Item(j).nodeTypedValue)
Set AtriXML = currNode.Attributes.item(1) ' Is it good???
Set VarValue = AtriXML.NodeValue ' Is it good???
 
Just use the getAttribute method.
For example childNodes.Item(j).getAttribute(&quot;Speciality&quot;)

Regards,

Oliver Talens
*****************************
Abyss I.T. Solutions
Mathildastraat 36B
4901 HC Oosterhout


tel: +31 (0)162-439809
fax: +31 (0)162-439882
O.Talens@Abyss.nl
*****************************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top