
}
return topLevel;
}
function resetAll(form,document)
{
var topLevel = document.documentElement;
document.removeChild(topLevel);
var output = form.output;
output.value = “”;
}
To create a new element in the XML document, the user enters the product
name and prices in dollars and in Euros and presses the
Create button. The
result is available in the text area. Figure 9.2 shows the result in a
browser.
281
Creating a New Document with DOM
Figure 9.2: The application in a browser
Creating Nodes
The following application simply creates new DOM objects and inserts
them in the document tree. It takes care to insert the new elements in the
appropriate order. Except that ...