This ticket contains documentation on functions that manipulate XML data.

  • (typGetXML {unid}) -> XML data reference: This function returns a reference to XML data representing the type's source code.
  • (xmlAppendSubElement {xml} {subelement} [index]) -> True/Nil Inserts an XML element in another XML element as a subelement before any existing subelement at index (0-indexed). If index is not specified, then the subelement is appended to the end.
  • (xmlAppendText {xml} {text} [index]) -> True/Nil: Appends string text to an XML element before any existing subelement at index (0-indexed). If index is not specified, the text is appended to the end. Text resides between subelements, though typically an element should not contain both text and subelements.
  • (xmlCreate {xml}) -> xml: If given XML data, then creates a copy of it and returns a reference to that copy. Functions applied to such a reference will not affect the original data. If given string data, attempts to convert the string to XML data (ensuring that it is well-formed) and returns a reference if successful and an error otherwise.
  • (xmlDeleteSubElement {element} {index}) -> True/Nil: Deletes the XML element's subelement at the specified index (0-indexed), returning True if index is lower than the element's subelement count (thus referring to a valid subelement) and Nil otherwise.
  • (xmlGetAttrib {element} {attrib}) -> value: Returns the value of the XML element's specified attribute, or Nil if the attribute is not defined.
  • (xmlGetAttribList {element}) -> string list: Returns a string list containing the names of all attributes defined on the XML element.
  • (xmlGetSubElement {element} {tag|index}) -> subelement: Retrieves from the XML element a reference to the first subelement with the given tag or the subelement at the specified index (if within range), if any exist. Returns Nil otherwise. Any functions applied to the subelement will affect the XML element that it came from.
  • (xmlGetSubElementCount {element}) -> number of subelements: Counts the subelements in element.
  • (xmlGetSubElementList {element} [tag]) -> list of subelements: Returns a list of references to the XML data of all the subelements in element. Any functions applied to the items will affect element.
  • (xmlGetTag {xml}) -> tag The tag of an element is the name of that element. For instance, the tag of <Events></Events> is Events.
  • (xmlGetText {element} {index}) -> text: Gets the element's text data located before the subelement at the specified index. Typically, XML elements should not contain both subelements and text, so the index is usually 0.
  • (xmlSetAttrib {element} {attrib} {value}) -> value: Sets the attribute and its value in the specified element, overwriting any existing attribute.
  • (xmlSetText {element} {text} [index]) -> True/Nil: Sets the element's text data located before the subelement at the specified index. Text data includes the newlines and whitespace between subelements, and any code block contained in the element. Typically, XML elements should not contain both subelements and text, so the index is usually 0.
relanat 22 Mar 2019:

Excellent work. Very handy. Thanks.