?
Solved

Parsing XML response. in ASP.

Posted on 2003-11-06
4
Medium Priority
?
439 Views
Last Modified: 2011-10-03
I am posting to an XML string as follows:

Set XMLRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
XMLRequest.open "POST", "http://gateway.textforce.net/sendsms.cfm", False
XMLRequest.SetRequestHeader "Host", "gateway.textforce.net"    
XMLRequest.SetRequestHeader "Connection", "Keep-Alive"
XMLRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
XMLRequest.send("xml=" & Server.URLEncode(xml))


The response I get I am trying to parse using the following code to get the StrRecipient and StrTransactionID values:

Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.loadXML(XMLRequest.responseXML.XML)
Set PathTempA = xmlDoc.selectSingleNode("SMSMessage/SMSMessageData")
Set PathTempB = xmlDoc.selectSingleNode("SMSMessage/SMSGateway")
StrRecipient = PathTempA.selectSingleNode("Recipient").text
StrTransactionID = PathTempB.selectSingleNode("TransactionID").text

All works fine until I try and insert an ampersand character in my post in the node named MessageText.  When it works, the XML response is:

  <?xml version="1.0" ?>
- <SMSMessage>
- <SMSAuthentication>
  <Username>xxx</Username>
  <Password>xxx</Password>
  </SMSAuthentication>
- <SMSMessageData>
  <Originator>TEXTCLEVER</Originator>
  <Recipient>xxx</Recipient>
  <MessageType>0</MessageType>
<MessageText>0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456780</MessageText>
  <ControlData />
  </SMSMessageData>
- <SMSGateway>
  <Response>00</Response>
  <TransactionID>6D2D1417-BF00-4852-98B4-A9EC130B7F96</TransactionID>
  <ErrorText />
  </SMSGateway>
  </SMSMessage>

When it fails , I get an error saying the 'PathTempA' Object not found.  When I click view source, the message says, 'The XML source file is unavailable for viewing'

Is there a differnet way to do this so that the response is returned correctly
0
Comment
Question by:videnda
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 15

Expert Comment

by:deighc
ID: 9702414
I don't really understand your question. You say the error occurs when you add an ampersand to your XML string, in which case you post a copy of that string so that we can look at it.

The problem is almost certain to be a character encoding issue. XML is very fussy about encoding. An ampersand should be encoded to &amp; and all other "funny" chars need to be encoded to &#[ascii char value];

Post a sample of your XML string and I'll see if I can help you more.
0
 

Author Comment

by:videnda
ID: 9730207
I have answered the question myself.

The responseXML.XML contained an ampersand, which caused an error.  I had to use responseText instead and replace the ampersand before loading the string in to the DOM object.

Thanks for you help.
0
 

Accepted Solution

by:
SpazMODic earned 0 total points
ID: 9755508
PAQed, with points refunded (50)

SpazMODic
EE Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question