Solved

Parse a URL key value

Posted on 2014-10-28
4
174 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 M earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now