当前位置 : 主页 > 编程语言 > c语言 >

vb.net – 拆分文本以获得特定值

来源:互联网 收集:自由互联 发布时间:2021-06-24
如何拆分此xml节点以仅获取数字值? spanAll Potatoes: 4/span 像这样的东西: Dim code as string = "spanAll Potatoes: 4/span"Dim splitrsult as stringSplitresult = splitresult("spanAll Potatoes:" "/span")Msgbox(splitresult)
如何拆分此xml节点以仅获取数字值?

<span>All Potatoes: 4</span>

像这样的东西:

Dim code as string = "<span>All Potatoes: 4</span>"
Dim splitrsult as string
Splitresult = splitresult("<span>All Potatoes:" & "</span>")
Msgbox(splitresult)

我是这种语言的新手,帮助会很感激.谢谢!

将XML作为XML处理! (不是简单的字符串)

使用此导入语句

Imports System.Xml.Linq

然后解析您的字符串以获取Xml元素并获取其值

Dim code As String = "<span>All Potatoes: 4</span>"
Dim node = XElement.Parse(code)
Dim result As String = node.Value ' ==> "All Potatoes: 4"
网友评论