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 December 15th, 2014, 07:51 AM
Registered User
 
Join Date: Dec 2014
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get XML Element Value with classic asp

Hi,

I have problem to get xml element value with classic asp.

This is the xml:

<?xml version="1.0" encoding="UTF-8"?>
-<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
-<soap:Body>
-<Add_ClubCustomer xmlns="http://someurl/">
<Add_ClubCustomerResult>1607</Add_ClubCustomerResult>
</Add_ClubCustomer >
</soap:Body>
</soap:Envelope>

I want to get the 1607 value in classic asp.

Thanks.
 
Old December 16th, 2014, 07:42 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

To be honest I have never hit a SOAP web service with ASP before. Here is how you work with an XML file

This is cut and paste code with two exceptions:
1.. replace someXMLFileName.xml with a valid XML file name. The code expects this file should be in the same dir as the ASP file calling it.
2.. replace 'firstName' and 'lastName' with two valid node names form your XML file. or you could use the example I ahve pasted at the end, it will simply run with this

Code:
Dim objxml,fName,lName
Set objxml = Server.CreateObject("MSXML2.DOMDocument")
objxml.async = False
objxml.load (Server.MapPath("someXMLFileName.xml"))
'get individual elements
set fName     = objxml.getElementsByTagName("firstName")
set lName     = objxml.getElementsByTagName("lastName")
response.write "The first name is = " & fName.item(0).Text & "<br>"
response.write "The last name is = " & lName.item(0).Text & "<br><br><bR>"

'or you can loop through liek this
dim nodeList, i
Set nodeList = objxml.SelectNodes("//xmldata/")
for each i In nodeList
    response.write(i.text & " -> Tag Name: " & i.nodeName & "<br />")
Next
an example of a vid XML file could be:

Code:
<xmldata>
  <people>
    <id>22506</id>
    <firstName>Jim</firstName>
	<lastName>Jones</lastName>
    <isAdmin>N</isAdmin>   
  </people>
</xmldata>
__________________
Wind is your friend
Matt

Last edited by mat41; December 16th, 2014 at 07:45 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT output to HTML - xml element text should look exactly as laid out in xml element DjGogga XSLT 4 July 21st, 2011 05:39 PM
classic ASP to ASP.NET 2.o XML coding rupen XML 10 May 18th, 2010 03:09 AM
classic ASP to ASP.NET 2.o XML coding rupen ASP.NET 2.0 Basics 0 May 14th, 2010 07:25 AM
converting classic asp to an xml page adamhw Classic ASP XML 10 December 7th, 2009 12:09 PM
Using ASP classic filesystem object to retrieve a xml file turns characters into Chin grotgod Classic ASP Basics 5 March 8th, 2009 03:07 PM





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