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

  • washer.xml
    309.6 KB · Views: 164

William Lancee

Well-Known Member
Licensed User
Longtime User
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:
    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

Chicao99

Member
Licensed User
Longtime User
No. It parses well-formed xml files.
For xml to be well-formed it needs a single root node.

B4X:
    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
Top