Solved

Parse a URL key value

Posted on 2014-10-28
4
181 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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