Reputation: 165
I'm aware of the default namespace in XML, e.g. declare xmlns="xxx" for an element, and this namespace will apply to all children without a prefix. My question is, if instead of xmlns="...", xmlns:pre="..." is declared in the element, are unprefixed child elements still associated with the namespace of the parent?
Here is an example:
<?xml version="1.0" ?>
<srv:tutorial xmlns:srv='http://www.w3resource.com/server-side-tutorial'>
<name>php</name>
<name>asp</name>
<name>jsp</name>
</srv:tutorial>
What is the namespace of the three inner name elements?
Upvotes: 7
Views: 2399
Reputation: 1788
All the three inner 'name' elements belong to the 'default' or 'empty' namespace, not the namespace prefixed with 'srv'.
Upvotes: 5