Table of Contents

KVSKBAVLOGXMLHandling

Procedures

AddRootElement(XmlDocument, Text, XmlElement) :

Summary: Adds a root element to the given XML document.

procedure AddRootElement(var xmlDocVar: XmlDocument; nodeNamePar: Text; var createdXMLNodeVar: XmlElement): 

Parameters:

  • xmlDocVar: The XML document to which the root element is added.
  • nodeNamePar: The name of the root element to create.
  • createdXMLNodeVar: Returns the created root XML element.

Remarks: The new element is inserted as the first node of the document.

AddRootElementWithPrefix(XmlDocument, Text, Text, Text, XmlElement) :

Summary: Adds a root element with a namespace prefix to the given XML document.

procedure AddRootElementWithPrefix(var xmlDocVar: XmlDocument; nodeNamePar: Text; prefixPar: Text; nameSpacePar: Text; var createdXMLNodeVar: XmlElement): 

Parameters:

  • xmlDocVar: The XML document to which the root element is added.
  • nodeNamePar: The name of the root element to create.
  • prefixPar: The namespace prefix to declare on the root element.
  • nameSpacePar: The namespace URI associated with the prefix.
  • createdXMLNodeVar: Returns the created root XML element.

Remarks: A namespace declaration attribute is added to the created element before inserting it into the document.

AddElement(XmlElement, Text, Text, Text, XmlElement) : Integer

Summary: Adds a child element with text content to the given XML element.

procedure AddElement(var xmlNodeVar: XmlElement; nodeNamePar: Text; nodeTextPar: Text; nameSpacePar: Text; var createdXMLNodeVar: XmlElement): Integer

Parameters:

  • xmlNodeVar: The parent XML element to which the child is added.
  • nodeNamePar: The name of the child element to create.
  • nodeTextPar: The text content of the child element.
  • nameSpacePar: The namespace URI for the child element.
  • createdXMLNodeVar: Returns the created child XML element.

Returns: Returns 0 on success.

Remarks: Delegates the actual node insertion to AddElementToNode.

AddElementWithPrefix(XmlElement, Text, Text, Text, Text, XmlElement) : Integer

Summary: Adds a child element with text content and a namespace prefix to the given XML element.

procedure AddElementWithPrefix(var xmlNodeVar: XmlElement; nodeNamePar: Text; nodeTextPar: Text; prefixPar: Text; nameSpacePar: Text; var createdXMLNodeVar: XmlElement): Integer

Parameters:

  • xmlNodeVar: The parent XML element to which the child is added.
  • nodeNamePar: The name of the child element to create.
  • nodeTextPar: The text content of the child element.
  • prefixPar: The namespace prefix to declare on the child element.
  • nameSpacePar: The namespace URI associated with the prefix.
  • createdXMLNodeVar: Returns the created child XML element.

Returns: Returns 0 on success.

Remarks: A namespace declaration attribute is added to the child element before insertion.

AddAttribute(XmlElement, Text, Text) : Integer

Summary: Adds an attribute to the given XML element.

procedure AddAttribute(var xmlNodeVar: XmlElement; namePar: Text; valuePar: Text): Integer

Parameters:

  • xmlNodeVar: The XML element to which the attribute is added.
  • namePar: The name of the attribute. If prefixed with 'xmlns:', a namespace declaration is created instead.
  • valuePar: The value of the attribute.

Returns: Returns 0 on success, or 50 if the node is empty.

Remarks: If the attribute name starts with 'xmlns:', the prefix is extracted and AddAttributeWithNamespaceDeclaration is called.

AddAttributeWithNamespaceDeclaration(XmlElement, Text, Text) : Integer

Summary: Adds a namespace declaration attribute to the given XML element.

procedure AddAttributeWithNamespaceDeclaration(var xmlNodeVar: XmlElement; prefixPar: Text; valuePar: Text): Integer

Parameters:

  • xmlNodeVar: The XML element to which the namespace declaration is added.
  • prefixPar: The namespace prefix for the declaration.
  • valuePar: The namespace URI for the declaration.

Returns: Returns 0 on success, or 50 if the node is empty.

Remarks: Uses XmlAttribute.CreateNamespaceDeclaration to build the attribute.

FindNode(XmlElement, Text, XmlNode) : Boolean

Summary: Finds the first XML node matching the given XPath within the specified root element.

procedure FindNode(xmlRootNodePar: XmlElement; nodePathPar: Text; var foundXMLNodeVar: XmlNode): Boolean

Parameters:

  • xmlRootNodePar: The root XML element to search within.
  • nodePathPar: The XPath expression to select the node.
  • foundXMLNodeVar: Returns the first matching XML node if found.

Returns: Returns true if a matching node is found, otherwise false.

Remarks: Returns false immediately if the root element is empty.

FindDocNodeWithNamespace(XmlDocument, Text, Text, Text, XmlNode) : Boolean

Summary: Finds the first XML node matching the given XPath in the document, using a namespace.

procedure FindDocNodeWithNamespace(xmlDocumentPar: XmlDocument; nodePathPar: Text; prefixPar: Text; nameSpacePar: Text; var foundXMLNodeVar: XmlNode): Boolean

Parameters:

  • xmlDocumentPar: The XML document to search within.
  • nodePathPar: The XPath expression to select the node.
  • prefixPar: The namespace prefix used in the XPath expression.
  • nameSpacePar: The namespace URI associated with the prefix.
  • foundXMLNodeVar: Returns the first matching XML node if found.

Returns: Returns true if a matching node is found, otherwise false.

Remarks: Retrieves the root element from the document and delegates to FindNodeWithNamespace.

FindNodeWithNamespace(XmlElement, Text, Text, Text, XmlNode) : Boolean

Summary: Finds the first XML node matching the given XPath within the root element, using a namespace.

procedure FindNodeWithNamespace(xmlRootNodePar: XmlElement; nodePathPar: Text; prefixPar: Text; nameSpacePar: Text; var foundXMLNodeVar: XmlNode): Boolean

Parameters:

  • xmlRootNodePar: The root XML element to search within.
  • nodePathPar: The XPath expression to select the node.
  • prefixPar: The namespace prefix used in the XPath expression.
  • nameSpacePar: The namespace URI associated with the prefix.
  • foundXMLNodeVar: Returns the first matching XML node if found.

Returns: Returns true if a matching node is found, otherwise false.

Remarks: Creates an XmlNamespaceManager with the given prefix and URI, then delegates to FindNodeWithNamespaceManager.

FindNodeWithNamespaceManager(XmlElement, Text, XmlNamespaceManager, XmlNode) : Boolean

Summary: Finds the first XML node matching the given XPath within the root element, using a namespace manager.

procedure FindNodeWithNamespaceManager(xmlRootNodePar: XmlElement; nodePathPar: Text; xmlNamespaceMgrPar: XmlNamespaceManager; var foundXMLNodeVar: XmlNode): Boolean

Parameters:

  • xmlRootNodePar: The root XML element to search within.
  • nodePathPar: The XPath expression to select the node.
  • xmlNamespaceMgrPar: The namespace manager providing prefix-to-URI mappings for the XPath.
  • foundXMLNodeVar: Returns the first matching XML node if found.

Returns: Returns true if a matching node is found, otherwise false.

Remarks: Returns false immediately if the root element is empty.

FindNodes(XmlElement, Text, XmlNodeList) : Boolean

Summary: Finds all XML nodes matching the given XPath within the specified root element.

procedure FindNodes(xmlRootNodePar: XmlElement; nodePathPar: Text; var foundXmlNodeListVar: XmlNodeList): Boolean

Parameters:

  • xmlRootNodePar: The root XML element to search within.
  • nodePathPar: The XPath expression to select nodes.
  • foundXmlNodeListVar: Returns the list of matching XML nodes if any are found.

Returns: Returns true if at least one matching node is found, otherwise false.

Remarks: Returns false immediately if the root element is empty.

FindNodesWithNamespace(XmlElement, Text, Text, Text, XmlNodeList) : Boolean

Summary: Finds all XML nodes matching the given XPath within the root element, using a namespace.

procedure FindNodesWithNamespace(xmlRootNodePar: XmlElement; nodePathPar: Text; prefixPar: Text; nameSpacePar: Text; var foundXmlNodeListVar: XmlNodeList): Boolean

Parameters:

  • xmlRootNodePar: The root XML element to search within.
  • nodePathPar: The XPath expression to select nodes.
  • prefixPar: The namespace prefix used in the XPath expression.
  • nameSpacePar: The namespace URI associated with the prefix.
  • foundXmlNodeListVar: Returns the list of matching XML nodes if any are found.

Returns: Returns true if at least one matching node is found, otherwise false.

Remarks: Creates an XmlNamespaceManager with the given prefix and URI, then delegates to FindNodesWithNamespaceManager.

FindDocNodesWithNamespaceManager(XmlDocument, Text, XmlNamespaceManager, XmlNodeList) : Boolean

Summary: Finds all XML nodes matching the given XPath in the document, using a namespace manager.

procedure FindDocNodesWithNamespaceManager(xmlDocumentPar: XmlDocument; nodePathPar: Text; xmlNamespaceMgrPar: XmlNamespaceManager; var foundXMLNodeListVar: XmlNodeList): Boolean

Parameters:

  • xmlDocumentPar: The XML document to search within.
  • nodePathPar: The XPath expression to select nodes.
  • xmlNamespaceMgrPar: The namespace manager providing prefix-to-URI mappings for the XPath.
  • foundXMLNodeListVar: Returns the list of matching XML nodes if any are found.

Returns: Returns true if at least one matching node is found, otherwise false.

Remarks: Retrieves the root element from the document and delegates to FindNodesWithNamespaceManager.

FindNodesWithNamespaceManager(XmlElement, Text, XmlNamespaceManager, XmlNodeList) : Boolean

Summary: Finds all XML nodes matching the given XPath within the root element, using a namespace manager.

procedure FindNodesWithNamespaceManager(xmlRootNodePar: XmlElement; nodePathPar: Text; xmlNamespaceMgrPar: XmlNamespaceManager; var foundXMLNodeListVar: XmlNodeList): Boolean

Parameters:

  • xmlRootNodePar: The root XML element to search within.
  • nodePathPar: The XPath expression to select nodes.
  • xmlNamespaceMgrPar: The namespace manager providing prefix-to-URI mappings for the XPath.
  • foundXMLNodeListVar: Returns the list of matching XML nodes if any are found.

Returns: Returns true if at least one matching node is found, otherwise false.

Remarks: Returns false immediately if the root element is empty.

FindDocNodeXMLWithNamespace(XmlDocument, Text, Text, Text) : Text

Summary: Returns the inner XML text of the first matching node in the document, using a namespace.

procedure FindDocNodeXMLWithNamespace(xmlDocumentPar: XmlDocument; nodePathPar: Text; prefixPar: Text; nameSpacePar: Text): Text

Parameters:

  • xmlDocumentPar: The XML document to search within.
  • nodePathPar: The XPath expression to select the node.
  • prefixPar: The namespace prefix used in the XPath expression.
  • nameSpacePar: The namespace URI associated with the prefix.

Returns: Returns the inner XML text of the found node, or an empty string if not found.

Remarks: Retrieves the root element from the document and delegates to FindNodeXMLWithNamespace.

FindDocNodeXMLWithNamespaceManager(XmlDocument, Text, XmlNamespaceManager) : Text

Summary: Returns the inner XML text of the first matching node in the document, using a namespace manager.

procedure FindDocNodeXMLWithNamespaceManager(xmlDocumentPar: XmlDocument; nodePathPar: Text; xmlNamespaceMgrPar: XmlNamespaceManager): Text

Parameters:

  • xmlDocumentPar: The XML document to search within.
  • nodePathPar: The XPath expression to select the node.
  • xmlNamespaceMgrPar: The namespace manager providing prefix-to-URI mappings for the XPath.

Returns: Returns the inner XML text of the found node, or an empty string if not found.

Remarks: Retrieves the root element from the document and delegates to FindNodeXMLWithNamespacemanager.

FindNodeXML(XmlElement, Text) : Text

Summary: Returns the inner XML text of the first node matching the given XPath within the root element.

procedure FindNodeXML(xmlRootNodePar: XmlElement; nodePathPar: Text): Text

Parameters:

  • xmlRootNodePar: The root XML element to search within.
  • nodePathPar: The XPath expression to select the node.

Returns: Returns the inner XML text of the found node, or an empty string if not found.

Remarks: Uses FindNode to locate the node and ReturnXMLNodeValue to extract its value.

FindNodeXMLWithNamespace(XmlElement, Text, Text, Text) : Text

Summary: Returns the inner XML text of the first node matching the given XPath within the root element, using a namespace.

procedure FindNodeXMLWithNamespace(xmlRootNodePar: XmlElement; nodePathPar: Text; prefixPar: Text; nameSpacePar: Text): Text

Parameters:

  • xmlRootNodePar: The root XML element to search within.
  • nodePathPar: The XPath expression to select the node.
  • prefixPar: The namespace prefix used in the XPath expression.
  • nameSpacePar: The namespace URI associated with the prefix.

Returns: Returns the inner XML text of the found node, or an empty string if not found.

Remarks: Uses FindNodeWithNamespace to locate the node and ReturnXMLNodeValue to extract its value.

FindNodeXMLWithNamespacemanager(XmlElement, Text, XmlNamespaceManager) : Text

Summary: Returns the inner XML text of the first node matching the given XPath within the root element, using a namespace manager.

procedure FindNodeXMLWithNamespacemanager(xmlRootNodePar: XmlElement; nodePathPar: Text; xmlNamespaceMgrPar: XmlNamespaceManager): Text

Parameters:

  • xmlRootNodePar: The root XML element to search within.
  • nodePathPar: The XPath expression to select the node.
  • xmlNamespaceMgrPar: The namespace manager providing prefix-to-URI mappings for the XPath.

Returns: Returns the inner XML text of the found node, or an empty string if not found.

Remarks: Uses FindNodeWithNamespaceManager to locate the node and ReturnXMLNodeValue to extract its value.

GetAttributeValue(XmlElement, Text) : Text

Summary: Returns the value of the specified attribute from the given XML element.

procedure GetAttributeValue(xmlNodePar: XmlElement; attributeNamePar: Text): Text

Parameters:

  • xmlNodePar: The XML element from which to retrieve the attribute value.
  • attributeNamePar: The name of the attribute whose value is to be retrieved.

Returns: Returns the attribute value as text, or an empty string if the attribute is not found or the element has no attributes.

Remarks: Iterates over all attributes of the element and returns the value of the first match.

GetNodelistElement(XmlNodeList, Integer, XmlElement) : Boolean

Summary: Retrieves an XML element from a node list by index.

procedure GetNodelistElement(xmlNodeListPar: XmlNodeList; indexpar: Integer; var xmlElementVar: XmlElement): Boolean

Parameters:

  • xmlNodeListPar: The XML node list to retrieve the element from.
  • indexpar: The 1-based index of the element to retrieve.
  • xmlElementVar: Returns the XML element at the specified index if found and of type XmlElement.

Returns: Returns true if the element is successfully retrieved and is an XmlElement, otherwise false.

Remarks: Returns false if the list is empty, the index exceeds the list count, the node cannot be retrieved, or the node is not an XmlElement.

AddDeclaration(XmlDocument, Text, Text, Text) :

Summary: Adds an XML declaration to the given XML document.

procedure AddDeclaration(var xmlDocVar: XmlDocument; versionPar: Text; encodingPar: Text; standalonePar: Text): 

Parameters:

  • xmlDocVar: The XML document to which the declaration is added.
  • versionPar: The XML version string (e.g. '1.0').
  • encodingPar: The encoding declaration (e.g. 'UTF-8').
  • standalonePar: The standalone declaration (e.g. 'yes' or 'no').

Remarks: Creates an XmlDeclaration and sets it on the document using SetDeclaration.