Report an issue
Class

CKEDITOR.xml

class

Represents a loaded XML document.

var xml = new CKEDITOR.xml( '<books><book title="My Book" /></books>' );

Filtering

Properties

  • baseXml : Object

    The native XML (DOM document) used by the class instance.

Methods

  • constructor( xmlObjectOrData ) → xml

    Creates xml class instance.

    Parameters

    xmlObjectOrData : Object | String

    A native XML (DOM document) object or a string containing the XML definition to be loaded.

    Returns

    xml
  • getInnerXml( xpath, [ contextNode ] ) → String

    Gets the string representation of hte inner contents of a XML node, based on a XPath query.

    // Create the XML instance.
    var xml = new CKEDITOR.xml( '<list><item id="test1" /><item id="test2" /></list>' );
    // Alert "<item id="test1" /><item id="test2" />".
    alert( xml.getInnerXml( 'list' ) );
    

    Parameters

    xpath : String

    The XPath query to execute.

    [ contextNode ] : Object

    The XML DOM node to be used as the context for the XPath query. The document root is used by default.

    Returns

    String

    The textual representation of the inner contents of the node or null if the query has no results.

  • selectNodes( xpath, [ contextNode ] ) → Array

    Gets a list node from the XML document, based on a XPath query.

    // Create the XML instance.
    var xml = new CKEDITOR.xml( '<list><item id="test1" /><item id="test2" /></list>' );
    // Get all <item> nodes.
    var itemNodes = xml.selectNodes( 'list/item' );
    // Alert "item" twice, one for each <item>.
    for ( var i = 0; i < itemNodes.length; i++ )
        alert( itemNodes[i].nodeName );
    

    Parameters

    xpath : String

    The XPath query to execute.

    [ contextNode ] : Object

    The XML DOM node to be used as the context for the XPath query. The document root is used by default.

    Returns

    Array

    An array containing all matched nodes. The array will be empty if the query has no results.

  • selectSingleNode( xpath, [ contextNode ] ) → Object

    Get a single node from the XML document, based on a XPath query.

    // Create the XML instance.
    var xml = new CKEDITOR.xml( '<list><item id="test1" /><item id="test2" /></list>' );
    // Get the first <item> node.
    var itemNode = <b>xml.selectSingleNode( 'list/item' )</b>;
    // Alert "item".
    alert( itemNode.nodeName );
    

    Parameters

    xpath : String

    The XPath query to execute.

    [ contextNode ] : Object

    The XML DOM node to be used as the context for the XPath query. The document root is used by default.

    Returns

    Object

    A XML node element or null if the query has no results.