ExtractXMLArray only extracts child elements with tag "element"

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Programie
User
User
Posts: 30
Joined: Thu Aug 09, 2007 11:26 am
Location: Gernsbach (Germany)
Contact:

ExtractXMLArray only extracts child elements with tag "element"

Post by Programie »

ExtractXMLArray() allows us to extract XML elements into an array. Unfortunately, this function expects a specific XML tag name for the child elements.

If we take the following example from the ExtractXMLArray() documentation it will work fine:

Code: Select all

Xml$ = "<array><element>1</element><element>10</element><element>100</element></array>"

If ParseXML(0, Xml$) And XMLStatus(0) = #PB_XML_Success
  Dim MyArray(0) ; will be resized by the next call
  ExtractXMLArray(MainXMLNode(0), MyArray())

  For i = 0 To ArraySize(MyArray())
    Debug MyArray(i)
  Next i
Else
  Debug XMLError(0)
EndIf
But once we change the tag name "element" to something else, it won't work anymore as ExtractXMLArray() is only searching for elements with the tag name "element".

Therefore, we can't use ExtractXMLArray() for XML structures using a different tag name for it's array elements.

ExtractXMLElement() should provide an additional parameter allowing the developer to define the tag name to use for searching for the child element. Or even better: Simply use all direct child elements independently of the name.
ImageImageImageImage
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: ExtractXMLArray only extracts child elements with tag "element"

Post by RSBasic »

+1, I confirm this.
Image
Image
Post Reply