load example


HTML document 

<html>

<head>
<title>example</title>
<SCRIPT>
function loadTree() {
 var diputree = parent.frames["diputree"].document.diputree;

 var root = "#xpointer(/))";
 var tree = "<diputree><has><b><lt>a branch</lt></b>" +
            "<l><lt>a leaf</lt></l></has></diputree>";
 diputree.load (root, tree);


 diputree.refresh(100);
}

function display() {
 var diputree = parent.frames["diputree"].document.diputree;
 var xml = diputree.save("#xpointer(/)");
 alert (xml);
}
</SCRIPT>
</head>

<body>

<form>
<p>Load the tree:
<p><input type="button" value="load" onClick="loadTree();">

<p>Display XML:
<p><input type="button" value="display" onClick="display();">
</form>

</body>
</html>

Explanation 

Load the xml document in the root.

 var root = "#xpointer(/))";

The tree variable contains the xml document to load.

 var tree = "<diputree><has><b><lt>a branch</lt></b>" +
            "<l><lt>a leaf</lt></l></has></diputree>";

Call the load method.

 diputree.load (root, tree);

Remarks

Instead of using the root ("xpointer(/)"), we could have used the document element ("#/1").


diputree documentation © 2000 dipu