Autore Topic: Errore con i tag XmlWriter in gb.xml  (Letto 8703 volte)

Offline Prokopy

  • Gamberetto
  • *
  • Post: 19
    • Mostra profilo
Re: Errore con i tag XmlWriter in gb.xml
« Risposta #75 il: 08 Luglio 2012, 21:35:54 »
This is solved in the last revision (#4915).

Offline sotema

  • Maestro Gambero
  • ****
  • Post: 467
    • Mostra profilo
Re: Errore con i tag XmlWriter in gb.xml
« Risposta #76 il: 08 Luglio 2012, 21:50:52 »
thanks.

Maybe another problem, maybe i misunderstood the doc:

XmlElement.GetAttribute (gb.xml)
Function GetAttribute ( Name As String ) As String
Returns the attribute Name.

Should return the Value of Attribute "Name"?

With the following code:

Codice: gambas [Seleziona]
Public Sub Main()
Dim oRoot As XmlElement
Dim oDoc As XmlDocument
Dim iVar As Integer
Dim oReader As XmlReader
  oDoc = New XmlDocument
  oDoc.Open("language")
  oRoot = oDoc.Root
  Debug oRoot.Name
  Debug oRoot.Children.Count
  For iVar = 0 To oRoot.ChildElements.Max
    Print oRoot.ChildElements[iVar].GetAttribute("name")
    Print oRoot.ChildElements[iVar].GetAttribute("code")
    Print oRoot.ChildElements[iVar].GetAttribute("region")
  Next
End


i got
name
code
region

while i expect:
Milan
MI
Lombardia

see the attached file.
L'uomo ha inventato la bomba atomica, ma nessun topo al mondo costruirebbe una trappola per topi.
Albert Einstein

Offline Prokopy

  • Gamberetto
  • *
  • Post: 19
    • Mostra profilo
Re: Errore con i tag XmlWriter in gb.xml
« Risposta #77 il: 08 Luglio 2012, 22:38:05 »
You're right, this should return the value of the attribute. I really hate this kind of stupid bugs...
This is solved in the revision #4917.

Offline sotema

  • Maestro Gambero
  • ****
  • Post: 467
    • Mostra profilo
Re: Errore con i tag XmlWriter in gb.xml
« Risposta #78 il: 09 Luglio 2012, 08:28:23 »
Rev #4919 it's ok
L'uomo ha inventato la bomba atomica, ma nessun topo al mondo costruirebbe una trappola per topi.
Albert Einstein

Offline sotema

  • Maestro Gambero
  • ****
  • Post: 467
    • Mostra profilo
Re: Errore con i tag XmlWriter in gb.xml
« Risposta #79 il: 09 Luglio 2012, 21:51:53 »
Hi Prokopy,
I have a bad new for you.
If you try to read an non existing Attribute a signal 11 occurs. (Rev. #4925)
Use the following code with the file cities attached in my previous post:
Codice: gambas [Seleziona]
Public Sub Main()
Dim oRoot As XmlElement  
Dim oDoc As XmlDocument  
Dim iVar As Integer  
Dim oReader As XmlReader  
 oDoc = New XmlDocument  
 oDoc.Open("cities.txt")  
 oRoot = oDoc.Root  
 Debug oRoot.Name  
 Debug oRoot.Children.Count  
 For iVar = 0 To oRoot.ChildElements.Max  
   Print oRoot.ChildElements[iVar].GetAttribute("name")  
   Print oRoot.ChildElements[iVar].GetAttribute("cod")  ' should be "code"
   Print oRoot.ChildElements[iVar].GetAttribute("region")  
 Next  
    
End

Attached the debugger output.
« Ultima modifica: 09 Luglio 2012, 21:59:56 da sotema »
L'uomo ha inventato la bomba atomica, ma nessun topo al mondo costruirebbe una trappola per topi.
Albert Einstein

Offline Prokopy

  • Gamberetto
  • *
  • Post: 19
    • Mostra profilo
Re: Errore con i tag XmlWriter in gb.xml
« Risposta #80 il: 10 Luglio 2012, 00:29:17 »
Hum, I think there is a mistake in your code. This line does not crashes :

Codice: gambas [Seleziona]
Print oRoot.ChildElements[iVar].GetAttribute("cod")


... but this one does :

Codice: gambas [Seleziona]
Print oRoot.ChildElements[iVar].Attributes["cod"]


We can see in the debugger output that the CElementAttributes_get method is called, not the CElement_getAttributes one.

Anyway, this is solved in the revision #4927. Thanks. :)

Offline sotema

  • Maestro Gambero
  • ****
  • Post: 467
    • Mostra profilo
Re: Errore con i tag XmlWriter in gb.xml
« Risposta #81 il: 10 Luglio 2012, 07:27:39 »
Hmmm, yes i made some bad cut & paste!

Thanks a lot.
L'uomo ha inventato la bomba atomica, ma nessun topo al mondo costruirebbe una trappola per topi.
Albert Einstein

Offline md9327

  • Moderatore
  • Senatore Gambero
  • *****
  • Post: 2.840
    • Mostra profilo
Re: Errore con i tag XmlWriter in gb.xml
« Risposta #82 il: 10 Luglio 2012, 12:43:26 »
sotema... You are always the same ...  ;D

Offline sotema

  • Maestro Gambero
  • ****
  • Post: 467
    • Mostra profilo
Re: Errore con i tag XmlWriter in gb.xml
« Risposta #83 il: 10 Luglio 2012, 15:53:38 »
yep  :-[
L'uomo ha inventato la bomba atomica, ma nessun topo al mondo costruirebbe una trappola per topi.
Albert Einstein

Offline md9327

  • Moderatore
  • Senatore Gambero
  • *****
  • Post: 2.840
    • Mostra profilo
Re: Errore con i tag XmlWriter in gb.xml
« Risposta #84 il: 31 Luglio 2012, 19:15:11 »
I have a small request to make to our friend Procopy.
In the production of an xml file, the XmlWriter (gb.xml and gb.libxml) creates a file with an indentation is not perfectly aligned. The closing tag does not respect the position initiated by the opening tag.
You can make sure to properly align the tags?
Obviously this is just a request you aesthetic ...

Thanks!!!  ;)