VB.NET : XML To JSON

Imports Newtonsoft.Json
Imports System.Xml

Module XMLtoJSON
Sub Main()
‘ Sample XML
Dim xml As String = “NavaFP01004882023-01-307000.00.08050.0S C 10 %700.0C.Gst 2.5 %175.0S.Gst 2.5 %175.0Credit CardSale

‘ Load XML to XmlDocument object
Dim doc As New XmlDocument()
doc.LoadXml(xml)

‘ Convert XmlDocument to Json string
Dim json As String = JsonConvert.SerializeXmlNode(doc)

‘ Print the Json string
Console.WriteLine(json)
Console.ReadLine()
End Sub
End Module

Scroll to Top