在经典ASP中解析网址 [英] parsing a url in classic asp
问题描述
您好,我试图解析从Web服务返回的url,并且我想解析返回的参数值,这就是从Web服务返回的url的外观
HREF =HTTP://emhaallrca/HMALED_EMH/edchartlink.aspx标记= wpLJXBWvloRJFKWY7UhAWSAJT4fHOW4dzLniQSkYRuTtvrq7rbugLvc%2f8FI%3D&图表= dLmvQiUSZQwaFHcfu1seUlOjAoKNfqEJyTF%2bRvkgv3mpHJynG3P5S1VjjTpPwMSJPLfDNTLbE0i8vdDU
我有兴趣获取令牌和图表的值.
我曾考虑过使用split()并将内容加载到数组中,但要查找起来并不容易.这是两个不同的值.
是否有人有任何建议或可以指出我可以阅读的文章. Google并没有太大帮助.
感谢
Hi All I trying to parse out a url that is being returned from a web service and I want to parse the parameter values returned this is what the url looks like when it is returned from the web service
href="http://emhaallrca/HMALED_EMH/edchartlink.aspx?token=wpLJXBWvloRJFKWY7UhAWSAJT4fHOW4dzLniQSkYRuTtvrq7rbugLvc%2f8FI%3d&chart=dLmvQiUSZQwaFHcfu1seUlOjAoKNfqEJyTF%2bRvkgv3mpHJynG3P5S1VjjTpPwMSJPLfDNTLbE0i8vdDU
Im interested in getting the values of token and chart.
I thought of using split() and load things in an array but it would be two different values to look for not easy.
Does anybody have any suggestion or can point me to an article I can read. Google hasn''t been much help.
Thanks
推荐答案
您的方向正确.您将需要执行split()
几次.首先以?"开头这将使用查询字符串中的网址.然后,在查询字符串上,用&"执行另一个split()
这会给你
token=wpLJXBWvloRJFKWY7UhAWSAJT4fHOW4dzLniQSkYRuTtvrq7rbugLvc%2f8FI%3d
chart=dLmvQiUSZQwaFHcfu1seUlOjAoKNfqEJyTF%2bRvkgv3mpHJynG3P5S1VjjTpPwMSJPLfDNTLbE0i8vdDU
现在,您可以使用另一个拆分进行处理,或者因为您知道自己的语法,就可以使用字符串操作.
You are in the right direction. You would need to dosplit()
few times. First with "?" this will device the url from the querystring. Then on the querystring you will do anothersplit()
with "&" which will give you
token=wpLJXBWvloRJFKWY7UhAWSAJT4fHOW4dzLniQSkYRuTtvrq7rbugLvc%2f8FI%3d
chart=dLmvQiUSZQwaFHcfu1seUlOjAoKNfqEJyTF%2bRvkgv3mpHJynG3P5S1VjjTpPwMSJPLfDNTLbE0i8vdDU
now either you can processed with another split or since your know your syntex you can use string manipulations.
Dim WordArray,WordArray1
WordArray=Split(TheUrl,"?")
WordArray=Split(WordArray(1),"&") ''Get two parameter expression
WordArray1 = Split(WordArray(0),"=")
token = WordArray1(1)
WordArray1 = Split(WordArray(1),"=")
chart = WordArray1(1)
这篇关于在经典ASP中解析网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!