[Gambas-user] Issue 352 in gambas: gambas3 XMLReader component generates wrong output (gambas2 was working fine)

gambas at ...2524... gambas at ...2524...
Thu Nov 22 17:13:40 CET 2012


Comment #4 on issue 352 by adrien.p... at ...626...: gambas3 XMLReader  
component generates wrong output (gambas2 was working fine)
http://code.google.com/p/gambas/issues/detail?id=352

I think I found the problem, but it comes from your code.
Here is the strange section :

If CStr(XmlR.Node.value) = "" Then
    StrHeader[XmlR.Node.depth] = XmlR.Node.name
End If

If I understood well the other parts of your code, you want to add the node  
name to your array when the reader reads the beginning of an element. But  
the node value is not empty only when reading the beginning of an element  
(that worked "by chance" with Gambas 2), so it will change the array  
values, and the output is finally not correct.

One good and safe way to detect the beginning of an element is to check the  
value of the XmlReader.State property :

If XmlR.State = XmlReaderNodeType.Element Then
         StrHeader[XmlR.Node.depth] = XmlR.Node.name
End If

With this code, the output is finally correct (I checked it well this  
time ;) ).
Regards,
Adrien





More information about the User mailing list