Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Parsing XML response. in ASP.

Posted on 2003-11-06
4
Medium Priority
?
442 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

Technology Partners: 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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

604 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