Wow
I just had my first opportunity to check this "As" casting stuff. OMG! this is so powerful!
Looking at..
So I tried to implement it in my sub here...
Off course, you need to understand exactly what you are trying to achieve.
Its such a breath of fresh air also that this works so seemlessly with BANano.
Awesome stuff guys!
Mashy ???
I just had my first opportunity to check this "As" casting stuff. OMG! this is so powerful!
Looking at..
B4X:
var doc_id = xmlDoc.getElementsByTagName("kml")[0].getElementsByTagName("Document")[0].id;
var doc_name = xmlDoc.getElementsByTagName("kml")[0].getElementsByTagName("name")[0].childNodes[0].nodeValue;
So I tried to implement it in my sub here...
B4X:
Sub UploadKMLFile(fileObj As Map)
'get the file details
Dim fileDet As FileObject
fileDet = BANanoShared.GetFileDetails(fileObj)
'get the file name
Dim fn As String = fileDet.FileName
fn = fn.tolowercase
'only process kml files
If fn.EndsWith(".kml") = False Then Return
'read the file contents as text
Dim kmlText As String = BANano.Await(vuetify.GetFileAsText(fileObj))
'convert to xml Doc
'var xmlDoc = (new DOMParser()).parseFromString(text, 'text/xml');
Dim domParser As BANanoObject
domParser.Initialize2("DOMParser", Null)
Dim xmlDoc As BANanoObject = domParser.RunMethod("parseFromString", Array(kmlText, "text/xml"))
'read the docID and docName
Dim kmlList As List = xmlDoc.RunMethod("getElementsByTagName", "kml")
Dim doc_id As String = kmlList.Get(0).As(BANanoObject).RunMethod("getElementsByTagName", "Document").As(List).Get(0).As(Map).Get("id")
Log(doc_id)
Dim childNodes As List = kmlList.Get(0).As(BANanoObject).RunMethod("getElementsByTagName", "name").As(List).Get(0).As(BANanoObject).GetField("childNodes").As(List)
Dim doc_name As String = childNodes.Get(0).As(BANanoObject).GetField("textContent").Result
Log(doc_name)
End Sub
Off course, you need to understand exactly what you are trying to achieve.
Its such a breath of fresh air also that this works so seemlessly with BANano.
Awesome stuff guys!
Mashy ???