Home > Software engineering >  The problem of VB to parse the XML
The problem of VB to parse the XML

Time:09-16

The following XML, suddenly can't laid hands on him, have a great god to see


































<15:02:31 valueString value="https://bbs.csdn.net/topics/2018-1-20"/& gt;





CodePudding user response:

Well, probably look at the...
A pile of unknown words...

CodePudding user response:

Use cutting, XML structure is not standard, not good reading, ResultData attribute I only wrote one, the rest of the mend his
 Private Sub Command1_Click () 
Dim r As New Result
R.D ata ResultData=https://bbs.csdn.net/topics/New

R.C ode=GetValue (" code ")
R.M essage=GetValue (" message ")
R.D ata. VirtualCardNum=GetValue (" virtualCardNum ")
MsgBox "code:" + r.C ode + vbCrLf + "message:" + _
VbCrLf r.M essage + + "Data. VirtualCardNum:" + r.D ata. VirtualCardNum
End Sub

The Function GetValue (paraname As String)
Dim res0 () As String
Res0=Split (Text1. The Text, the name "value=" "" & amp; Paraname & amp; "" "")
If UBound (res0)=1 Then
Res1=Split (res0 (1), "& lt; ValueString value="" ")
Then If UBound (res1)=0
GetValuehttps://bbs.csdn.net/topics/=""
The Else
If InStr (res1 (1), "" "") & gt; 0 Then
GetValue=https://bbs.csdn.net/topics/Split (res1 (1), "" "") (0)
The Else
GetValuehttps://bbs.csdn.net/topics/="NUL
"End the If
End the If
The Else
GetValuehttps://bbs.csdn.net/topics/="NUL
"End the If
End the Function



The Result class
 Private varcode As String, varmessage As String 
Private vardata As ResultData
Public Property Let Code (ByVal vcode As String)
Varcode=vcode
End Property

Public Property Get Code () As String
Code=varcode
End Property

Public Property Let the Message (ByVal vmessage As String)
Varmessage=vmessare
End Property

Public Property Get Message () As String
Message=varmessage
End Property

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related