Mostbet  |   Blog  |   Sitemap  |   Search  
HomeBlogDefault namespaces in DOM

Oh, these confusing default namespaces in DOM

Apparently some (wink!) people have troubles understanding how DOM treats default namespaces. To clarify the issue, let us consider a piece of XML parsed in an Namespaces-aware DOM implementation.


In the table below you can see what namespaces get elements and attributes:

element/attribute namespaceURI
element1 null
attribute1 null
attribute2 null
element3 null
attribute3 null
From the spec: If there is a default namespace declaration in scope, the expanded name corresponding to an unprefixed element name has the URI of the default namespace as its namespace name. If there is no default namespace declaration in scope, the namespace name has no value. The namespace name for an unprefixed attribute name always has no value.