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!

read xml string 1

Status
Not open for further replies.

thompom

Technical User
Dec 4, 2006
395
GB
Hi,

This is my first foray into xml and am stuck trying to read a node from an xml string.
I want to read the node called 'Url' but just keep getting
cant find node

any ideas welcome

asp
Code:
Set xml = CreateObject("Microsoft.XMLDOM") 
xml.async = False 
xml.LoadXml(objHTTP.responseText) 

set node = xml.selectSingleNode("/QuotesResponse/QuotesResult/InsuranceCalculationResult/CustomerDetailsForm/Url")
if node is nothing then
    response.write "Could not find Node"
else
    response.write node.text
end if

set objDoc = nothing


my xml looks like
Code:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/envelope/"[/URL] xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
<soap:Body>
<QuotesResponse xmlns="[URL unfurl="true"]http://www.somesite.com">[/URL]
<QuotesResult>
<InsuranceCalculationResult xmlns="[URL unfurl="true"]http://www.somesite.com">/webservices/">[/URL]
<CustomerDetailsForm>
<Url>[URL unfurl="true"]https://www.somesite.com/blahblah</Url>[/URL]
<DisplayText>Text</DisplayText>
</CustomerDetailsForm>
</InsuranceCalculationResult>
</QuotesResult>
</QuotesResponse>
</soap:Body>
</soap:Envelope>
 
Code:
<%
Dim oxml
Set oxml = Server.CreateObject("Microsoft.XMLDOM")
oxml.async = False
' i stored your XML as a file, so:
oxml.load (Server.MapPath("tt.xml"))

' Case sensitive!
Set nodesURL=oXML.documentElement.selectNodes("//Url")
response.Write nodesURL(0).text 
Set nodesURL = Nothing
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top