[Gambas-user] Problem reading attributes from XML file

T Lee Davidson t.lee.davidson at ...626...
Sat Feb 27 23:38:24 CET 2016


Hi Markus,

I created a quick command-line version with your procedures. It works fine on v3.6.2. I get a collection returned with length of 
one and a value of "http://exist.sourceforge.net/NS/exist".

Perhaps something has happened to your gb.xml component?


On 02/27/2016 04:35 PM, Markus Schatten wrote:
> Dear friends,
>
> I have a piece of code that was recently working, but for some reason
> it stopped (using 3.5.4. currently). What I would like to do is simply
> read out all attributes and their values (if they exists) from an
> XmlNode. Here is what I do:
>
> Public Sub btnLoad_Click()
>    Dim xml As New XmlDocument
>    Dim txt As String
>    Dialog.Filter = ["*.xml", "XML Documents"]
>    If Dialog.OpenFile() Then Return
>    txt = File.Load(Dialog.Path)
>    xml.FromString(txt)
>    parse(xml.Root)
> End
>
> Public Sub parse(node As XmlNode) As Collection
>    Dim child As XmlNode
>    Dim ret As New Collection
>    If node.Attributes Then
>      For Each child In node.Attributes
>        ret["@" & child.Name] = child.Value
>      Next
>    Endif
>    Return ret
> End
>
> The XML file I'm trying to read is:
>
> <exist:result xmlns:exist="http://exist.sourceforge.net/NS/exist">
>      <exist:collection name="/db"
> created="2016-02-27T19:24:55.787+01:00" owner="SYSTEM" group="dba"
> permissions="rwxr-xr-x">
>          <exist:collection name="apps"
> created="2016-02-27T19:25:36.612+01:00" owner="SYSTEM" group="dba"
> permissions="rwxr-xr-x"/>
>          <exist:collection name="system"
> created="2016-02-27T19:24:55.792+01:00" owner="SYSTEM" group="dba"
> permissions="rwxr-xr-x"/>
>      </exist:collection>
> </exist:result>
>
> What happens is that in the parse function on the first entry into the
> for each loop the app crashes and the following message is displayed
> in the console:
>
> FATAL : tried to create a Gambas object with invalid type.
>
> I've lost the few past hours searching for a solution, but the only
> thing that I found is that the error is thrown in node.cpp from the
> gb.xml source (e.g. here
> https://github.com/justlostintime/gambas/blob/master/gb.xml/src/node.cpp).
>
> What am I doing wrong? How should I get all attributes from an XmlNode?
>
> All the best,
>
> M.
>
>
> --
> Markus Schatten, PhD
> Assistant professor and head of Artificial Intelligence Lab
> University of Zagreb
> Faculty of Organization and Informatics
> Pavlinska 2, 42000 Varazdin, Croatia
> http://www.foi.hr/nastavnici/schatten.markus/index.html
> http://www.researchgate.net/profile/Markus_Schatten1
> http://ai.foi.hr
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>

-- 
Lee
__________

"Artificial Intelligence is no match for natural stupidity."




More information about the User mailing list