Android Question Xml2map

Chicao99

Member
Licensed User
Longtime User
Does this library only parse html tags? Is there anyway to parse other kind of document, like this one attached? I'm getting "org.apache.harmony.xml.ExpatParser$ParseException: At line 3, column 0: junk after document element".
Tks.
 

Attachments

Does this library only parse html tags?
No. It parses well-formed xml files.
For xml to be well-formed it needs a single root node.

B4X: Copy
    Dim fileData As String = $"<Root>${File.ReadString(File.DirAssets, "washer.xml")}</Root>"$
    Dim xm As Xml2Map 
    xm.Initialize
    Private ParsedData As Map = xm.Parse(fileData)
    Dim Root As Map = ParsedData.Get("Root")
    Dim Geometry As Map = Root.Get("Geometry")
    Log(GetElements(Geometry, "Face").Size)        'Log: 31
 
Upvote 1
No. It parses well-formed xml files.
For xml to be well-formed it needs a single root node.

B4X: Copy
    Dim fileData As String = $"<Root>${File.ReadString(File.DirAssets, "washer.xml")}</Root>"$
    Dim xm As Xml2Map
    xm.Initialize
    Private ParsedData As Map = xm.Parse(fileData)
    Dim Root As Map = ParsedData.Get("Root")
    Dim Geometry As Map = Root.Get("Geometry")
    Log(GetElements(Geometry, "Face").Size)        'Log: 31

Thank you very much William!!!
 
Upvote 0

Similar Threads

Back
Top