[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New 'gb.xml2' component


Le 08/11/2026 à 11:06, Claus Dietrich a écrit :
Am 08.11.26 um 01:03 schrieb Claus Dietrich:
Methods have partially changed and essential classes like XMLElement are not available any longer. I do not see myself in a position to rewrite the project and test the new component without further documentation or information.
Am 08.11.26 um 09:29 schrieb Benoît Minisini:
I just need to know what features are missing in the new 'gb.xml2'.

How can we iterate through XML elements with gb.xml2 without a class like 'XmlElement' as offered by gb.xml?

Best regards

Claus

You should read the 'libxml2' documentation, alas it is not very easy to read (more difficult than the Gambas documentation!).

There is two ways of parsing an XML document:

1) The 'XmlDocument' class. It loads the document in memory entirely (from a file or a string), and creates a tree of 'XmlNode' and 'XmlAttribute' objects. The 'XmlNode' should be your 'XmlElement'.

The 'XmlDocument.Root' returns the root 'XmlNode' of the XML document. Then you can use the 'XmlNode.Children' property to browse the children nodes, and 'XmlNode.Attributes' property to browse the node attributes.

The funny thing in 'libxml2' is that 'XmlNode' and 'XmlAttribute' are almost managed the same way (this is why I think it is named "node" and not "element"), but I made the distinction better in the the 'gb.xml2' API.

2) The 'XmlReader" class. It does not load the document in memory, it browses the nodes one by one while reading the document.

You call the 'XmlReader.Read()' method to read the next node, and access the current node properties with 'XmlReader.Node'. The node attributes are returned by 'XmlReader.Node.Attributes' as a Gambas collection (the key is the attribute name, the value is the attribute value).

I didn't write any documentation yet, as the component API is not really finished.

By the way I have just starting to implement in 'XmlDocument' the ability to modify the document, but it is not finished (you should be able to save your changes for example).

Regards,

--
Benoît Minisini.


Follow-Ups:
Re: New 'gb.xml2' componentgbWilly <gbWilly@xxxxxxxxxxxxxx>
Re: New 'gb.xml2' componentClaus Dietrich <claus.dietrich@xxxxxxxxxx>
References:
New 'gb.xml2' componentBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: New 'gb.xml2' componentBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: New 'gb.xml2' componentClaus Dietrich <claus.dietrich@xxxxxxxxxx>
Re: New 'gb.xml2' componentBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: New 'gb.xml2' componentClaus Dietrich <claus.dietrich@xxxxxxxxxx>
Re: New 'gb.xml2' componentClaus Dietrich <claus.dietrich@xxxxxxxxxx>
Re: New 'gb.xml2' componentClaus Dietrich <claus.dietrich@xxxxxxxxxx>