InsertXMLList()

Syntax

Result = InsertXMLList(ParentNode, List() [, PreviousNode])
Description
Insert the specified List() 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.
List() The list 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 "list" and the contained element nodes are named "element". See below for an example of the created XML.

Example

  ; This example produces the following XML tree:
  ;
  ; <list>
  ;   <element>square</element>
  ;   <element>circle</element>
  ;   <element>triangle</element>
  ; </list>
  ;
  NewList Shapes$()
  AddElement(Shapes$()): Shapes$() = "square"
  AddElement(Shapes$()): Shapes$() = "circle"
  AddElement(Shapes$()): Shapes$() = "triangle"

  If CreateXML(0)
    InsertXMLList(RootXMLNode(0), Shapes$())
    FormatXML(0, #PB_XML_ReFormat)
    Debug ComposeXML(0)
  EndIf

Example

  ; This example produces the following XML tree:
  ;
  ; <list>
  ;   <element>
  ;     <x>100</x>
  ;     <y>200</y>
  ;   </element>
  ;   <element>
  ;     <x>200</x>
  ;     <y>400</y>
  ;   </element>
  ; </list>
  ;
  Structure Position
    x.l
    y.l
  EndStructure
  
  NewList Positions.Position()
  
  For i = 1 To 2
    AddElement(Positions())
    Positions()\x = 100 * i
    Positions()\y = 200 * i
  Next i

  If CreateXML(0)
    InsertXMLList(RootXMLNode(0), Positions())
    FormatXML(0, #PB_XML_ReFormat)
    Debug ComposeXML(0)
  EndIf

See Also

ExtractXMLList(), InsertXMLArray(), InsertXMLMap(), InsertXMLStructure()

Supported OS

All

<- InsertXMLArray() - XML Index - InsertXMLMap() ->