Solved

Parse a URL key value

Posted on 2014-10-28
4
186 Views
Last Modified: 2014-10-28
I need to parse this:

"<key><cv><c>ID</c><v>245</v></cv></key>"

I used QueryString("parm_name") to obtain this value.  I need the 245.  Now , I could just use Split or some other general parse mechanism, but is that a specific URL parse mechanism to do this?
0
Comment
Question by:HLRosenberger
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
Ron Malmstead earned 500 total points
ID: 40408957
If I understand correctly.. you're already using the normal way to parse a key/val URL, ..using "QueryString", ..and this string is the entire value..so yes, you will have to parse it yourself.

Try this..

Dim val as string = cstr("<key><cv><c>ID</c><v>245</v></cv></key>").ToString.Replace("<v>", "~").Replace("</v>", "~").Split("~").GetValue(1).ToString
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 40409006
ok.  thanks.  I thought maybe I was doing something wrong,  I'm using a thirds party product that generates the WEB pages, so I suppose they are using this format on the URL parms.
0
 
LVL 5

Expert Comment

by:ReneD100
ID: 40409084
Or you can parse the XML using system.xml - you can also easily access the rest of the string:
Imports System.XML
Public Sub test()
        Dim strData As String = "<key><cv><c>ID</c><v>245</v></cv></key>"
        Dim xmlDoc As New XmlDocument
        xmlDoc.LoadXml(strData)
        Dim xmlNode As XmlNodeList = xmlDoc.GetElementsByTagName("v")
        MessageBox.Show(xmlNode(0).InnerXml)
End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 40409125
thanks
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

820 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