Le Fri, 11 Aug 2017 00:37:02 +0200, Karl Reinl <karl.re...@fen-net.de> a écrit:

Am Donnerstag, den 10.08.2017, 23:11 +0200 schrieb Adrien Prokopowicz:
Le Thu, 10 Aug 2017 18:42:37 +0200, Hans Lehmann <h...@gambas-buch.de> a
écrit:
> Hello Adrian,
>Thank you for this example in the playground. Now I can successfully
> work with the component gb.xml.
>To the red marked lines in the source text section, I find no
> description in the documentation.
>Questions: What is the meaning of the Boolean property ReadFlags with
> regard to the use of the class XmlReader?What is the effect of setting
> the value to False?
>Public Sub btnParseXMLNodes_Click()
>  txaNodes.Clear   xmlReader.Open(sXMLPath)
>   xmlReader.ReadFlags[XmlReaderNodeType.Element] = True
>    xmlReader.ReadFlags[XmlReaderNodeType.Attribute] = True
>   xmlReader.Read()
>   While Not xmlReader.Eof
>    ...
>   Wend
>  End
> Regards Hans

When a ReadFlag is set to False, the Read() method will skip the
corresponding
XML node type if it encounters it.
By default they are all set to True, setting them to true manually won't
do anything.

Here is an example, you can toggle the ReadFlags and see the result :

https://gambas-playground.proko.eu/?gist=b90eeff3dacbec0548d01701f3c05133


Salut Adrian,

is it the lib, the example or the playground. Have a look to the
attached screen. All ReadFlags are set to False, but I get a '6
endelement'

It is a mistake in my example code.
Because all flags are set to false, the XmlReader will skip through the entire
document until it hits the end (Eof).

However, becaused I used a Repeat-Until loop, the Print still gets executed once, and the XmlReader.Node.Type property returns the type of what the reader read last,
which is the end of the root element.

A correct (although a bit more verbose) version of the example would be this :
https://gambas-playground.proko.eu/?gist=9e84746e67859a9dacb55ec2dba34575

--
Adrien Prokopowicz

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to