Solved

Split content of return post data, possibly using a dictionary object

Posted on 2012-04-04
2
296 Views
Last Modified: 2012-04-05
I am using ServerXMLHTTP to post to a server and the return post data coming back to me needs to be parsed in to a format I can use. The data is coming back to me like the below :

POST.VALIDATION=ACK&FRONTEND.REDIRECT_URL=https%3A%2F%2Ftest.ctpe.net%2Ffrontend%2FstartFrontend.prc%3Bjsessionid%gg.sbg-vm-fe01&P3.VALIDATION=ACK 

Open in new window


What I want to do is split name / value pairs and, ideally, be able to reference the name value, i.e. be able to test if there is a dictionary item called POST.VALIDATION and what the value is.
0
Comment
Question by:AbeSpain
2 Comments
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 37811711
there's no straightforward way to do this, you'll need to split each key/value string, then split each key and value into seperate values.

I'm assuming the "splitter" is the "&" symbol, correct? if so, the code would be:

   data = "POST.VALIDATION=ACK&FRONTEND.REDIRECT_URL=https%3A%2F%2Ftest.ctpe.net%2Ffrontend%2FstartFrontend.prc%3Bjsessionid%gg.sbg-vm-fe01&P3.VALIDATION=ACK"

   Set dictData = Server.CreateObject("Scripting.Dictionary")
   arrData = Split( data, "&" )

   for each keyValuePair in arrData
      arrKeyValuePair = Split( keyValuePair, "=" )      '-- the splitter is now the equals sign
      dictData.Add arrKeyValuePair( 0 ), arrKeyValuePair( 1 )
   next

Open in new window


now all the data is in the dictData dictionary object. For more info, see  http://www.w3schools.com/asp/asp_ref_dictionary.asp

edit: one typo in the code snippet I gave you, now fixed
0
 

Author Comment

by:AbeSpain
ID: 37812295
That's similar to how I did it in the end, I appreciate the reply :)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
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/…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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