Android Question meta tag parse

Almora

Active Member
Licensed User
hi..

I converted the html page to xml.
I want to parse the image with xml2map.
there are two problems

1:I get the error as mentioned
2:do I parse an image in meta tags. (xxxx.jpg)

1
main2_activity_create (java line: 412)
java.lang.ClassCastException: anywheresoftware.b4a.objects.collections.Map$MyMap cannot be cast to java.util.List
at b4a.exammjhple.main2._activity_create(main2.java:412)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at b4a.exammjhple.main2.afterFirstLayout(main2.java:104)
at b4a.exammjhple.main2.access$000(main2.java:17)
at b4a.exammjhple.main2$WaitForLayout.run(main2.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAn


2(log)

** Activity (main2) Create, isFirst = true **
log: HTML: <meta http-equiv="pragma" content="no-cache">
log: HTML: <meta http-equiv="expires" content="-1">
log: HTML: <meta http-equiv="cache-control" content="no-cache">
log: HTML: <meta name="" content="text ">
log: HTML: <meta name="" content="website">
log: HTML: <meta name="" content="//www.website.com">
log: HTML: <meta name="" content="Starlingtar">
log: HTML: <meta name="" content="//website1/images/xxxx.jpg">
log: HTML: <meta name="" content="image/png">
log: HTML: <meta name="" content="300">
log: HTML: <meta name="" content="300">
log: HTML: <meta name="" content="t_T">
log: Google Tag Manager
log: HTML: <noscript>

dArgsCaller.run(ZygoteInit.java:866)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)





{
"article": {
"lang": "",
"para": [
{
"note": [
{"remark": "HTML: <meta http-equiv=\"pragma\" content=\"no-cache\">"},
{"remark": "HTML: <meta http-equiv=\"expires\" content=\"-1\">"},
{"remark": "HTML: <meta http-equiv=\"cache-control\" content=\"no-cache\">"},
{"remark": "HTML: <meta name=\"\" content=\"text \">"},
{"remark": "HTML: <meta name=\"\" content=\"website\">"},
{"remark": "HTML: <meta name=\"\" content=\"//www.website.com\">"},
{"remark": "HTML: <meta name=\"\" content=\"Starling\">"},
{"remark": "HTML: <meta name=\"\" content=\"//website1/images/xxxx.jpg\">"},
{"remark": "HTML: <meta name=\"\" content=\"image/png\">"},
{"remark": "HTML: <meta name=\"\" content=\"300\">"},
{"remark": "HTML: <meta name=\"\" content=\"300\">"},
{"remark": "HTML: <meta name=\"\" content=\"t_T\">"},
{"remark": "Google Tag Manager"},
{"remark": "HTML: <noscript>"},
{"remark": "HTML: <\/noscript>"},
{"remark": "End Google Tag Manager"}
],
"anchor": {"id": "body"},
"content": [
.........................
..................
...........
.....
...
.
.



B4X:
    Dim article As Map = ParsedData.Get("article")
    Dim para As List = article.Get("para")   
    For Each colpara As Map In para
        Dim note As List = colpara.Get("note")   
            For Each colnote As Map In note
            Dim remark As String = colnote.Get("remark")       
            Log($"log: ${remark}"$)       
        Next

thank you...
 

Almora

Active Member
Licensed User
{
"article": {
"Attributes": {
"lang": ""
},
"para": [
{
"note": [
{
"remark": "HTML: <meta http-equiv=\"pragma\" content=\"no-cache\">"
},
{
"remark": "HTML: <meta http-equiv=\"expires\" content=\"-1\">"
},
{
"remark": "HTML: <meta http-equiv=\"cache-control\" content=\"no-cache\">"
},
{
"remark": "HTML: <meta name=\"\" content=\"text \">"
},
{
"remark": "HTML: <meta name=\"\" content=\"website\">"
},
{
"remark": "HTML: <meta name=\"\" content=\"\/\/www.website.com/\">"

},
{
"remark": "HTML: <meta name=\"\" content=\"Starling\">"
},
{
"remark": "HTML: <meta name=\"\" content=\"\/\/website1\/images\/xxxx.jpg\">"
},
{
"remark": "HTML: <meta name=\"\" content=\"image\/png\">"
},
{
"remark": "HTML: <meta name=\"\" content=\"300\">"
},
{
"remark": "HTML: <meta name=\"\" content=\"300\">"
},
{
"remark": "HTML: <meta name=\"\" content=\"t_T\">"
},
{
"remark": "Google Tag Manager"
},
{
"remark": "Google Tag Manager"
},
{
"remark": "HTML: <noscript>"
},
{
"remark": "HTML: <\/noscript>"
},
{
"remark": "End Google Tag Manager"
}
],
"anchor": {
"Attributes": {
"id": "body"
},
"Text": ""
}
},
{
"olink": {
"Attributes": {


........
.....
...
..
 

Almora

Active Member
Licensed User
B4X:
   If FirstTime Then
     Dim xm As Xml2Map
     xm.Initialize
        ParsedData = xm.Parse(File.ReadString(File.DirAssets, "htmltoxml.xml"))
   End If
   Activity.LoadLayout("2")

'    Dim article As Map = ParsedData.Get("article")
'    Dim para As List = article.Get("para")   
'    For Each colpara As Map In para
'        Dim note As List = colpara.Get("note")   
'            For Each colnote As Map In note
'            Dim remark As String = colnote.Get("remark")       
'            Log($"log: ${remark}"$)       
'        Next
Log(jg.ToPrettyString(4))
I'm getting this log with this code. ---->>(')












B4X:
   If FirstTime Then
     Dim xm As Xml2Map
     xm.Initialize
        ParsedData = xm.Parse(File.ReadString(File.DirAssets, "htmltoxml.xml"))
   End If
   Activity.LoadLayout("2")

    Dim article As Map = ParsedData.Get("article")
    Dim para As List = article.Get("para")
    For Each colpara As Map In para
        Dim note As List = colpara.Get("note")
        For Each colnote As Map In note
        Dim remark As String = colnote.Get("remark")
        Log($"log: ${remark}"$)
        Next

        Next
with this code the log shows after getting the error. ---->>()


..
...
…..
log: HTML: <meta name="" content="300">
log: HTML: <meta name="" content="t_T">
log: Google Tag Manager
log: HTML: <noscript>
log: HTML: </noscript>
log: End Google Tag Manager
main2_activity_create (java line: 389)
java.lang.RuntimeException: Object should first be initialized (List).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.collections.List.getSize(List.java:129)
at b4a.exammjhple.main2._activity_create(main2.java:389)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at b4a.exammjhple.main2.afterFirstLayout(main2.java:104)
at b4a.exammjhple.main2.access$000(main2.java:17)
at b4a.exammjhple.main2$WaitForLayout.run(main2.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
 

Almora

Active Member
Licensed User
B4X:
{
"remark": "HTML: <meta name=\"\" content=\"Starling\">"
},
{
"remark": "HTML: <meta name=\"\" content=\"\/\/website1\/images\/xxxx.jpg\">"
},
{
"remark": "HTML: <meta name=\"\" content=\"image\/png\">"
},
{
"remark": "HTML: <meta name=\"\" content=\"300\">"
},


How to get xxxx.jpg image
how to name the "remark".
 
Top