CreateXML()

Syntax

Result = CreateXML(#XML [, Encoding])
Description
Creates a new empty XML tree identified by the #XML number.

Parameters

#XML A number to identify the new XML. #PB_Any can be used to auto-generate this number.
Encoding (optional) The encoding to use for the XML tree. Valid values are:
  #PB_UTF8 (default)
  #PB_Ascii
  #PB_Unicode

Return value

Nonzero if the XML tree was created successfully, zero otherwise. If #PB_Any was used for the #XML parameter then the generated number is returned on success.

Remarks

The new XML 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), "Zoo") 
  
  ; Create first xml node (in main node)
  item = CreateXMLNode(mainNode, "Animal") 
  SetXMLAttribute(item, "id", "1") 
  SetXMLNodeText(item, "Elephant") 
  
  ; Create second xml node (in main node)
  item = CreateXMLNode(mainNode, "Animal") 
  SetXMLAttribute(item, "id", "2") 
  SetXMLNodeText(item, "Tiger") 
  
  ; Save the xml tree into a xml file
  SaveXML(xml, "demo.xml")

See Also

FreeXML(), CreateXMLNode(), RootXMLNode()

Supported OS

All

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