InsertXMLArray()

Syntax

Result = InsertXMLArray(ParentNode, Array() [, PreviousNode])
Description
Insert the specified Array() as a new XML node into the given parent node.

Parameters

ParentNode The node into which to insert the new node. To insert the new node at the root of the tree, RootXMLNode() can be used here.
Array() The array to insert into the XML.
PreviousNode (optional) A childnode of 'ParentNode' after which the new node should be inserted. If this value is 0 or not specified, the new node is inserted as the first child of its parent. If this value is -1, the node is inserted as the last child of its parent.

Return value

The new XML node if it was created successfully or zero if no node could be inserted at this point.

Remarks

The rules specified in the CreateXMLNode() for where a new node can be inserted also apply to this function.

The inserted node is named "array" and the contained element nodes are named "element". If the array has multiple dimension, each element will have attributes indicating the coordinate of the element within the array, with each coordinate named "a", "b" and so forth. See below for an example of the created XML.

Example

  ; This example produces the following XML tree:
  ;
  ; <array>
  ;   <element>red</element>
  ;   <element>green</element>
  ;   <element>blue</element>
  ; </array>
  ;
  Dim Colors$(2)
  Colors$(0) = "red"
  Colors$(1) = "green"
  Colors$(2) = "blue"
  
  If CreateXML(0)
    InsertXMLArray(RootXMLNode(0), Colors$())
    FormatXML(0, #PB_XML_ReFormat)
    Debug ComposeXML(0)
  EndIf

Example

  ; This example produces the following XML tree:
  ;
  ; <array>
  ;   <element a="0" b="0">0</element>
  ;   <element a="0" b="1">1</element>
  ;   <element a="1" b="0">10</element>
  ;   <element a="1" b="1">11</element>
  ;   <element a="2" b="0">20</element>
  ;   <element a="2" b="1">21</element>
  ; </array>
  ;
  Dim MultiArray(2, 1)
  For a = 0 To 2
    For b = 0 To 1
      MultiArray(a, b) = a * 10 + b
    Next b
  Next a
  
  If CreateXML(0)
    InsertXMLArray(RootXMLNode(0), MultiArray())
    FormatXML(0, #PB_XML_ReFormat)
    Debug ComposeXML(0)
  EndIf

See Also

ExtractXMLArray(), InsertXMLList(), InsertXMLMap(), InsertXMLStructure(),

Supported OS

All

<- GetXMLStandalone() - XML Index - InsertXMLList() ->