Ballerina API Documentation

Functions of ballerina.lang.xmls package

function addAttribute(xml x, string xPath, string name, string value)

Adds an attribute to the XML element that matches the given XPath. If the XPath matches the text value of an existing element, or if the XPath does not match an existing element, this operation will have no effect.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath
namestringName of the attribute to be added
valuestringAttribute value

function addAttribute(xml x, string xPath, string name, string value, map namespaces)

Adds an attribute to the XML element that matches the given XPath. If the XPath matches the text value of an existing element, or if the XPath does not match an existing element, this operation will have no effect. Namespaces are supported.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath
namestringName of the attribute to be added
valuestringAttribute value
namespacesmapA map object consisting of namespaces

function addElement(xml x, string xPath, xml value)

Adds an XML element to the location that matches the given XPath. If the XPath matches the text value of an existing element, or if the XPath does not match an existing element, this operation will have no effect.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath
valuexmlAn XML value

function addElement(xml x, string xPath, xml value, map namespaces)

Adds an XML element to the location that matches the given XPath. If the XPath matches the text value of an existing element, or if the XPath does not match an existing element, this operation will have no effect. Namespaces are supported.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath
valuexmlAn XML value
namespacesmapA map object consisting of namespaces

function getString(xml x, string xPath) (string )

Evaluates the XPath on an XML object and returns the matching string value.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath

Return Parameters:

Return VariableData TypeDescription
stringMatching string value

function getString(xml x, string xPath, map namespaces) (string )

Evaluates the XPath on an XML object and returns the matching string value. Namespaces are supported.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath
namespacesmapA map object consisting of namespaces

Return Parameters:

Return VariableData TypeDescription
stringMatching string value

function getXml(xml x, string xPath) (xml )

Evaluates the XPath on an XML object and returns the matching XML object.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath

Return Parameters:

Return VariableData TypeDescription
xmlMatching XML object

function getXml(xml x, string xPath, map namespaces) (xml )

Evaluates the XPath on an XML object and returns the matching XML object. Namespaces are supported

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath
namespacesmapA map object consisting of namespaces

Return Parameters:

Return VariableData TypeDescription
xmlMatching XML object

function remove(xml x, string xPath)

Removes the element(s) that match the given XPath.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath

function remove(xml x, string xPath, map namespaces)

Removes the element(s) that match the given XPath. Namespaces are supported.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath
namespacesmapA map object consisting of namespaces

function set(xml x, string xPath, string value)

Sets the string value of an element that matches the given XPath. If the XPath matches an existing element, that element's value will be updated. If the XPath does not match an existing element, this operation will have no effect.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath
valuestringx: An XML object

function set(xml x, string xPath, string value, map namespaces)

Sets the string value of an element that matches the given XPath. If the XPath matches an existing element, that element's value will be updated. If the XPath does not match an existing element, this operation will have no effect. Namespaces are supported.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath
valuestringA string value
namespacesmapA map object consisting of namespaces

function set(xml x, string xPath, xml value)

Sets the XML value of an element that matches the given XPath. If the XPath matches an existing element, that element's value will be updated. If the XPath does not match an existing element, this operation will have no effect.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath
valuexmlAn XML value

function set(xml x, string xPath, xml value, map namespaces)

Sets the XML value of an element that matches the given XPath. If the XPath matches an existing element, that element's value will be updated. If the XPath does not match an existing element, this operation will have no effect. Namespaces are supported.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object
xPathstringAn XPath
valuexmlAn XML value
namespacesmapA map object consisting of namespaces

function toString(xml x) (string )

Converts an XML object to a string representation.

Parameters:

Parameter NameData TypeDescription
xxmlAn XML object

Return Parameters:

Return VariableData TypeDescription
stringString value of the converted XML


Menu

  • Functions
    • addAttribute(xml x, string xPath, string name, string value)
    • addAttribute(xml x, string xPath, string name, string value, map namespaces)
    • addElement(xml x, string xPath, xml value)
    • addElement(xml x, string xPath, xml value, map namespaces)
    • getString(xml x, string xPath) (string )
    • getString(xml x, string xPath, map namespaces) (string )
    • getXml(xml x, string xPath) (xml )
    • getXml(xml x, string xPath, map namespaces) (xml )
    • remove(xml x, string xPath)
    • remove(xml x, string xPath, map namespaces)
    • set(xml x, string xPath, string value)
    • set(xml x, string xPath, string value, map namespaces)
    • set(xml x, string xPath, xml value)
    • set(xml x, string xPath, xml value, map namespaces)
    • toString(xml x) (string )

Copyright 2017 Ballerina API Documentation