getName


String getName (String xpointer)

Returns the name of the matching element.

 xpointer The name the first matching element for xpointer will be returned.

Code snippet

Get the type of the first node ("b" for branch and "l" for leaf)

var docElem = "#/1)";
var xptr = "#xpointer(has/*[1])";
var element = diputree.lookup(docElem,xptr);

if ( element=="" ) {
    alert ("No elements available.");
} else {
    var type = diputree.getName(element);
    if (type=="b") {
        alert ("The first element is a branch");
    } else {
        alert ("The first element is a leaf");
    }
}

Example

getName example


diputree documentation © 2000 dipu