Results 1 to 2 of 2

Thread: XML over HTTP

  1. #1
    Join Date
    Dec 1969

    Default XML over HTTP

    I am sending some data to another site which returns me an XML document. Once I recieve this code, I want to find the value of two tags "TransitTime" and "NetCharge". Here is the code I am using to send and recieve the XML document, now how can I parse the data recieved from the response to get the numbers in these fields. <BR>&#060;TransitTime&#062;654&#060;/TransitTime&#062; <BR>&#060;NetCharge&#062;1234&#060;/NetCharge&#062; <BR><BR>Here is the code I am using so far and I am recieving the XML document correctly. <BR><BR>rateRequest = Server.URLEncode(rateRequest) <BR>set httpConn = CreateObject("Microsoft.XMLHTTP") &#039create obj <BR>httpConn.open "POST","http://www.con-way.com/xml/x-rate.asp", false <BR>httpConn.setRequestHeader "Content-type", "application/x-www-form-urlencoded" <BR>httpConn.Send "RateRequest=" & rateRequest <BR><BR>set rateQuote = CreateObject("Microsoft.XMLDOM") <BR>rateQuote.loadXML(httpConn.responseText) <BR><BR>This is where I am stuck. <BR>Thanks

  2. #2
    Harrison Guest

    Default RE: XML over HTTP

    Here is how I get to a specific element, you can also loop through the structure if you need mulitple fields...<BR><BR>&#039 Check to make sure no parsing errors occurred during load<BR>If rateQuote.ParseError.ErrorCode = 0 then<BR> Dim objElement<BR> Dim objNode<BR> Dim strVariable<BR><BR> Set objElement=rateQuote.getElementsByTagName("Transit Time")<BR> Set objNode = objElement.Item(0)<BR> strVariable = objNode.Text<BR><BR>objElement is an array, but as long as you don&#039t have the same element name appear twice in your XML doc, you&#039ll always get the one you want in the index 0 position.<BR><BR>The strVariable will now hold the contents of the element you specify in the&#039getElementsByTagName&#039 method.<BR><BR>Harrison

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts