The links above deal with XML directly but most of the time developers want to deserialize XML into a type similar to the previous post only on the server. This stuff is also openly published.
Imports Newtonsoft
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports System
Imports System.IO
Imports System.Security.Cryptography
Imports System.Xml.Serialization
Module Module1
Sub Main()
Dim strXML As String = "<NewDataSet>
<USPWEB>
<NUMBER>4112344112344113</NUMBER>
<CTYPE>VI</CTYPE>
<EXPIRATION>0623</EXPIRATION>
<ACCOUNT>2036220196290</ACCOUNT>
<STATUS>A</STATUS>
<DEFAULT>N</DEFAULT>
<TYPE>R</TYPE>
<DATE>2016-04-11T11:02:13-04:00</DATE>
<ACCOUNTREFID>100001</ACCOUNTREFID>
<NTITY>BILLPAY</NTITY>
<STRRETVAL>99</STRRETVAL>
</USPWEB>
</NewDataSet>"
Dim serializer As XmlSerializer = New XmlSerializer(GetType(NewDataSet))
Using reader As New StringReader(strXML)
Dim ds As NewDataSet = serializer.Deserialize(reader)
Console.WriteLine(ds.USPWEB.ACCOUNT)
End Using
End Sub
End Module
<System.SerializableAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=True), _
System.Xml.Serialization.XmlRootAttribute([Namespace]:="", IsNullable:=False)> _
Partial Public Class NewDataSet
Private uSPWEBField As NewDataSetUSPWEB
'''<remarks/>
Public Property USPWEB() As NewDataSetUSPWEB
Get
Return Me.uSPWEBField
End Get
Set
Me.uSPWEBField = Value
End Set
End Property
End Class
'''<remarks/>
<System.SerializableAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=True)> _
Partial Public Class NewDataSetUSPWEB
Private nUMBERField As ULong
Private cTYPEField As String
Private eXPIRATIONField As UShort
Private aCCOUNTField As ULong
Private sTATUSField As String
Private dEFAULTField As String
Private tYPEField As String
Private dATEField As Date
Private aCCOUNTREFIDField As UInteger
Private nTITYField As String
Private sTRRETVALField As Byte
'''<remarks/>
Public Property NUMBER() As ULong
Get
Return Me.nUMBERField
End Get
Set
Me.nUMBERField = Value
End Set
End Property
'''<remarks/>
Public Property [CTYPE]() As String
Get
Return Me.cTYPEField
End Get
Set
Me.cTYPEField = Value
End Set
End Property
'''<remarks/>
Public Property EXPIRATION() As UShort
Get
Return Me.eXPIRATIONField
End Get
Set
Me.eXPIRATIONField = Value
End Set
End Property
'''<remarks/>
Public Property ACCOUNT() As ULong
Get
Return Me.aCCOUNTField
End Get
Set
Me.aCCOUNTField = Value
End Set
End Property
'''<remarks/>
Public Property STATUS() As String
Get
Return Me.sTATUSField
End Get
Set
Me.sTATUSField = Value
End Set
End Property
'''<remarks/>
Public Property [DEFAULT]() As String
Get
Return Me.dEFAULTField
End Get
Set
Me.dEFAULTField = Value
End Set
End Property
'''<remarks/>
Public Property TYPE() As String
Get
Return Me.tYPEField
End Get
Set
Me.tYPEField = Value
End Set
End Property
'''<remarks/>
Public Property [DATE]() As Date
Get
Return Me.dATEField
End Get
Set
Me.dATEField = Value
End Set
End Property
'''<remarks/>
Public Property ACCOUNTREFID() As UInteger
Get
Return Me.aCCOUNTREFIDField
End Get
Set
Me.aCCOUNTREFIDField = Value
End Set
End Property
'''<remarks/>
Public Property NTITY() As String
Get
Return Me.nTITYField
End Get
Set
Me.nTITYField = Value
End Set
End Property
'''<remarks/>
Public Property STRRETVAL() As Byte
Get
Return Me.sTRRETVALField
End Get
Set
Me.sTRRETVALField = Value
End Set
End Property
End Class
None
0 Points
13 Posts
String Function
Feb 11, 2019 06:14 PM|mansooraabid|LINK
I have...
Dim strXML as string="<NewDataSet>
<USPWEB>
<NUMBER>4112344112344113</NUMBER>
<CTYPE>VI</CTYPE>
<EXPIRATION>0623</EXPIRATION>
<ACCOUNT>2036220196290</ACCOUNT>
<STATUS>A</STATUS>
<DEFAULT>N</DEFAULT>
<TYPE>R</TYPE>
<DATE>2016-04-11T11:02:13-04:00</DATE>
<ACCOUNTREFID>100001</ACCOUNTREFID>
<NTITY>BILLPAY</NTITY>
<STRRETVAL>99</STRRETVAL>
</USPWEB>
</NewDataSet>"
Now I want a function(strXML.<someFunction>) where I can find the value for STRRETVAL is 99
*STRRETVAL May be or may not be, we have to check first if it exists
* STRRETVAL can have any number or character
All-Star
50854 Points
12100 Posts
Re: String Function
Feb 11, 2019 08:05 PM|bruce (sqlwork.com)|LINK
pretty simple in javascript/jquery
:
None
0 Points
13 Posts
Re: String Function
Feb 11, 2019 08:53 PM|mansooraabid|LINK
I have to do this in code behind, I cannot implement jQuerry :(
Can u please give me code behind logic
All-Star
37221 Points
15032 Posts
Re: String Function
Feb 11, 2019 09:16 PM|mgebhard|LINK
.NET has quite extensive openly published and extremely easy to find XML support. I type VB XML in an internet search and founds these excellent docs.
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/xml/
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/xml/manipulating-xml
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/concepts/linq/parsing-xml
The links above deal with XML directly but most of the time developers want to deserialize XML into a type similar to the previous post only on the server. This stuff is also openly published.
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/concepts/linq/how-to-serialize-using-xmlserializer
https://docs.microsoft.com/en-us/dotnet/api/system.xml.serialization.xmlserializer.deserialize?view=netframework-4.7.2
All-Star
50854 Points
12100 Posts
Re: String Function
Feb 11, 2019 11:48 PM|bruce (sqlwork.com)|LINK
then do not ask in jQuery forum. if you have code behind, then its probably should be asked in the web form forum.