Re: [Gambas-user] XML - Display structure

2017-08-12 Thread Adrien Prokopowicz

Le Sat, 12 Aug 2017 22:59:13 +0200,  a écrit:

Don't want to sound pedantic or be the wiseguy that states the obvious,  
but I think this is a perfect example for a recursive call.


The way I picture this is a routine that initially receives the XML root  
node and displays all its attributes and text. Then, it calls itself  
recursively for each subnode.


To mantain GUI hierarchy, a second optional parameter may be set to the  
parent node key in a treeview. This parameter is initially not passed  
when the node is root.


Hope it helps,
zxMarce.



This is exactly what the example I attached is. :-)

--
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


Re: [Gambas-user] XML - Display structure

2017-08-12 Thread d4t4full
Don't want to sound pedantic or be the wiseguy that states the obvious, but I 
think this is a perfect example for a recursive call.

The way I picture this is a routine that initially receives the XML root node 
and displays all its attributes and text. Then, it calls itself recursively for 
each subnode.

To mantain GUI hierarchy, a second optional parameter may be set to the parent 
node key in a treeview. This parameter is initially not passed when the node is 
root.

Hope it helps,
zxMarce.


On Aug 12, 2017, 13:43, at 13:43, Adrien Prokopowicz 
 wrote:
>Le Fri, 11 Aug 2017 14:25:33 +0200, Hans Lehmann 
>a  
>écrit:
>
>>
>> Hello,
>>
>> I am unable to read and display the structure of the following XML
>file  
>> xml.xml:
>> [...]
>> Does anyone have an idea or suggestion or even a finished solution
>for  
>> the above mentioned task? My projects with >XmlDocument and XmlReader
>do  
>> not display the structure of the xml.xml file correctly. But: Other
>XML  
>> files are displayed >correctly. We are looking for a (general)
>solution  
>> for any XML files.
>>
>
>The problem in your code is here :
>
> For Each xChild In xmlElement.ChildElements
>   'Extract Element-Value if the element has no children
>   If (xChild.ChildElements.Count = 0) Then
>
>You are assuming elements have either text or other elements in them,
>but  
>your
>E3 element has both.
>
>To do this, you have to treat each element separately, and to iterate
>on  
>all
>node types using the Children property (not just Elements, which is
>what  
>the
>ChildElements property does).
>
>The attached example gives a simple solution to your problem.
>
>Regards,
>
>-- 
>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
--
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


Re: [Gambas-user] XML - Display structure

2017-08-12 Thread Adrien Prokopowicz
Le Fri, 11 Aug 2017 14:25:33 +0200, Hans Lehmann  a  
écrit:




Hello,

I am unable to read and display the structure of the following XML file  
xml.xml:

[...]
Does anyone have an idea or suggestion or even a finished solution for  
the above mentioned task? My projects with >XmlDocument and XmlReader do  
not display the structure of the xml.xml file correctly. But: Other XML  
files are displayed >correctly. We are looking for a (general) solution  
for any XML files.




The problem in your code is here :

For Each xChild In xmlElement.ChildElements
  'Extract Element-Value if the element has no children
  If (xChild.ChildElements.Count = 0) Then

You are assuming elements have either text or other elements in them, but  
your

E3 element has both.

To do this, you have to treat each element separately, and to iterate on  
all
node types using the Children property (not just Elements, which is what  
the

ChildElements property does).

The attached example gives a simple solution to your problem.

Regards,

--
Adrien Prokopowicz

XmlTree-0.0.1.tar.gz
Description: GNU Zip compressed data
--
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