[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New 'gb.xml2' component
[Thread Prev] | [Thread Next]
- Subject: Re: New 'gb.xml2' component
- From: gbWilly <gbWilly@xxxxxxxxxxxxxx>
- Date: Sun, 08 Nov 2026 19:50:24 +0000
- To: Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
- Cc: user@xxxxxxxxxxxxxxxxxxxxxx
On Sunday, November 8th, 2026 at 19:41, Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> wrote: > 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, > > -- The parsing of a document using either XmlDocument or XmlReader seems the same as in the previous gb.xml. The first is in memory, the second acts like stream and is less memory hungry (as explained on the wiki: https://gambaswiki.org/wiki/doc/xml). But, I'm in no way an xml expert, I just happen to be needing for data exchange with an external application, that's why I'm looking into it all. I do think a sort of translation table telling what in gb.xml is replaced by what in gb.xml2 would be welcomed. I for example discovered that one of the arguments in several of the XmlWriter methods that used to be a String array, now is collections, and that several methods have changed name, like Text becoming AddText etc. So a one-on-one code transfer is a no go, you'll need to run through it all. I do not get a simple StartElement in XmlWriter to work in gb.xml2, although I think the syntax should be correct (see my other post for that). Is that a bug? gbWilly
| Re: New 'gb.xml2' component | Karl Reinl <karl.reinl@xxxxxxxxxx> |
| New 'gb.xml2' component | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |
| Re: New 'gb.xml2' component | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |
| Re: New 'gb.xml2' component | Claus Dietrich <claus.dietrich@xxxxxxxxxx> |
| Re: New 'gb.xml2' component | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |
| Re: New 'gb.xml2' component | Claus Dietrich <claus.dietrich@xxxxxxxxxx> |
| Re: New 'gb.xml2' component | Claus Dietrich <claus.dietrich@xxxxxxxxxx> |
| Re: New 'gb.xml2' component | Claus Dietrich <claus.dietrich@xxxxxxxxxx> |
| Re: New 'gb.xml2' component | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |