Dim str as string = "<request id=value1 type=value2>value3</request>"
如何选择值如下......
Dim id as string = get the value of id (value1)
Dim type as string = get the value of type (value 2)
Dim ReadValue3 as string = get the value3
答案 0 :(得分:3)
好吧,我不明白为什么你需要使用LINQ本身,但你当然可以使用LINQ to XML:
Dim element as XElement = XElement.Parse(str)
Dim id as String = CType(element.Attribute("id"), String)
Dim type as String = CType(element.Attribute("type"), String)
Dim value as String = element.Value
(如果VB有语法问题,请道歉......这不是我的母语,可以这么说。)
答案 1 :(得分:0)
注意可以使用带有字符串的linq http://msdn.microsoft.com/en-us/library/bb397915.aspx
你在处理xml时不会想要