Interview Questions

How do I override a default XML namespace declaration?

XML Interview Questions and Answers


(Continued from previous question...)

70. How do I override a default XML namespace declaration?

To override the current default XML namespace, you simply declare another XML namespace as the default. For example, in the following, the default XML namespace is the http://www.google.org/ namespace on the A and B elements and the http://www.bar.org/ namespace on the C and D elements. That is, the names A and B are in the http://www.google.org/ namespace and the names C and D are in the http://www.bar.org/ namespace.

<A xmlns="http://www.google.org/">
<B>
<C xmlns="http://www.bar.org/">
<D>abcd</D>
</C>
</B>
</A>

Using multiple default XML namespaces can lead to documents that are confusing to read and should be done carefully.

(Continued on next question...)

Other Interview Questions