• Topic
  • Discussion
  • OATWikiWeb.OATDOCxml(Last) -- Owiki? , 2016-08-19 14:58:53 Edit owiki 2016-08-19 14:58:53


    Useful function for XML access and manipulation.



    Parses a string of XML data and returns a document object.

    OAT.Xml.transformXSLT(xmlDoc, xslDoc[, paramsArray])

    Applies a XSLT template. xslDoc is a template to be applied to xmlDoc. Both arguments must be valid XML documents (not strings). The third (optional) argument is an array of XSLT parameters. Each parameter is a triple (array), which consists of Namespace, Name, and Value.


    Returns a text value of node. So, for the markup below, the textValueof tag is content --



    Returns node's local name - the part without namespace prefix.<xsl:template> has a localName template.


    Returns all child nodes which are ordinary elements (i.e., no#textnodes, etc.).

    OAT.Xml.getElementsByLocalName(node, localName)

    Identical to getElementsByTagName, but looks only into non-namespace part of tag name.

    OAT.Xml.getLocalAttribute(node, attributeName)

    Returns a value of attribute whose non-prefixed name is attributeName


    Takes an XML document in string form and removes default namespace. This is useful when we want to use XPath queries against such a document, since these cannot be executed against documents with default namespaces. Returns XML string.

    OAT.Xml.xpath(xmlDoc, xPathQuery, nsObject)

    Runs an XPath query (xPathQuery) against xmlDoc. Namespaces are resolved as properties of nsObject.


    Returns escaped.


    Returns unescaped.


    Example 1

    var xmlDoc, xslDoc; // somehow fill these with data
    var params = [
    var result = OAT.Xml.transformXSLT(xmlDoc, xslDoc, params);

    Example 2

    var xmlString = '<?xml version="1.0" ?><document><node>value</node><node /></document>';
    var xmlDoc = OAT.Xml.createXmlDoc(xmlString);
    var nodeArray = OAT.Xml.xpath(xmlDoc, '//node', {});
    alert(nodeArray.length); // 2

    Referenced by...