How can I split this xml node to get only the number value?
<span>All Potatoes: 4</span>
Something like this:
Dim code as string = "<span>All Potatoes: 4</span>"
Dim splitrsult as string
Splitresult = splitresult("<span>All Potatoes:" & "</span>")
Msgbox(splitresult)
I'm newbie in this language, and help would be appreciate it. Thank you!
Handle the XML as XML! (not as a simple string)
Use this imports statement
Imports System.Xml.Linq
Then parse your string in order to get an Xml element and get its value
Dim code As String = "<span>All Potatoes: 4</span>"
Dim node = XElement.Parse(code)
Dim result As String = node.Value ' ==> "All Potatoes: 4"
To get the number value using Regex: (It's simple. Never be afraid of Regex)
Dim code as string = "<span>All Potatoes: 4</span>"
resultString = Regex.Match(code, @"\d+").Value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With