CreateXML()

Syntax

Result = CreateXML(#XML [, Encoding])
Description
Creates a new empty XML tree identified by the #XML number. If #PB_Any is used as '#XML' parameter, the new XML tree number will be returned as 'Result'. 'Encoding' specifies the encoding to use for the tree. Valid values are #PB_Ascii, #PB_Unicode or #PB_UTF8. (#PB_UTF8 is the default)

The new tree will only have a root node which can be accessed with RootXMLNode(). To add new nodes, CreateXMLNode() can be used.

Example:

  ; Create xml tree
  xml = CreateXML(#PB_Any) 
  mainNode = CreateXMLNode(RootXMLNode(xml)) 
  SetXMLNodeName(mainNode, "Zoo") 
  
  ; Create first xml node (in main node)
  item = CreateXMLNode(mainNode) 
  SetXMLNodeName(item, "Animal") 
  SetXMLAttribute(item, "id", "1") 
  SetXMLNodeText(item, "Elephant") 
  
  ; Create second xml node (in main node)
  item = CreateXMLNode(mainNode) 
  SetXMLNodeName(item, "Animal") 
  SetXMLAttribute(item, "id", "2") 
  SetXMLNodeText(item, "Tiger") 
  
  ; Save the xml tree into a xml file
  SaveXML(xml, "demo.xml")

Supported OS

All

<- CopyXMLNode() - XML Index - CreateXMLNode() ->