To preface this I see Erel has released a class which may help you. See here; https://www.b4x.com/android/forum/t...ple-way-to-parse-xml-documents.74848/#content
I primarily use JSON in my day job so XML is not my forte. I had to parse some simple XML files from a web service. I tried XML SAX but it was way too complicated. I tried to use the java object "toJSONObject" method but this proved unreliable especially when some items in the XML were sometimes a single item but sometimes a collection.
Anyway, I came across this library;
https://github.com/toastedcode/SimpleXML
I have ported this to a B4J Library (attached). The library uses XPath to search through XML. I found this approach much more palatable for my use.
Sample code below.
Not all functionality is implemented (eg its read only right now).
I primarily use JSON in my day job so XML is not my forte. I had to parse some simple XML files from a web service. I tried XML SAX but it was way too complicated. I tried to use the java object "toJSONObject" method but this proved unreliable especially when some items in the XML were sometimes a single item but sometimes a collection.
Anyway, I came across this library;
https://github.com/toastedcode/SimpleXML
I have ported this to a B4J Library (attached). The library uses XPath to search through XML. I found this approach much more palatable for my use.
Sample code below.
B4X:
Dim x As SimpleXMLWrapper
x.Initialize(Manifest)
Dim L As List
L.Initialize
L = x.GetNodesValues("/SVCManifest/Resources/SVCResource/OnPremisePath")
MXD = L.Get(0)
If MXD = "" Then MXD = "Unknown"
L = x.GetNodesValues("/SVCManifest/Databases/SVCDatabase/Datasets/SVCDataset/OnPremisePath")
For Each node As String In L
Log(node)
Next
Not all functionality is implemented (eg its read only right now).
Attachments
Last edited: