An important addition to DOM Level 2 not yet
discussed is DOM’s support for XML namespaces.
You’ll remember from Chapter 3 and
Chapter 4, that SAX 2.0 added
namespace support, and the same is true
for the second iteration of DOM. The key here is two new methods on
. Additionally, all of the
creation methods have namespace-aware
versions available. So, instead of calling
createElement( ), you call
In each of these new namespace-aware methods, the first argument is
the namespace URI, and the second is the
qualified name of the element, attribute, etc.
Note that I said qualified; this means that if you want to use a
namespace URI of “http://www.oreilly.com” and a prefix of
“ora” on an element called “copyright”, you
createElementNS("http://www.oreilly.com", "ora:copyright"). This is very ...