ZVON > References > DOM2 Reference

createElementNS (method )

Owning interface and usage:  
Document.createElementNS(namespaceURI, qualifiedName)

Member of these other interfaces:  
none

Description:  
Creates an element of the given qualified name and namespace URI.

Parameters:  
DOMString namespaceURI  - 
DOMString qualifiedName  - 

Returns:  
Element -  A new Element object. (For complete list of attributes of created Element object see standard.)

Exceptions:  
DOMException INVALID_CHARACTER_ERR
Raised if the specified qualified name contains an illegal character.
DOMException NAMESPACE_ERR
Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace".


Example:
Text in the first DIV.
x a b x
Text in the last DIV.
Source:
   <div id="doc" xmlns:svg="http://www.w3.org/2000/svg">
     <div>
       Text in the first DIV.
     </div>
     <svg:svg id="logo" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="60">
       <svg:g style="fill:#3399cc; font-size:36pt; font-family:'dialog'; font-weight: bold">
         <svg:a xlink:type="simple" xlink:href="http://www.zvon.org">
           <svg:text x="50%" y="65%" text-anchor="middle">ZVON.org</svg:text>
         </svg:a>
       </svg:g>
     </svg:svg>
     <apply xmlns="http://www.w3.org/1998/Math/MathML">
   <int/> 
   <bvar> 
     <ci> x </ci> 
   </bvar> 
   <interval> 
     <ci> a </ci> 
     <ci> b </ci> 
   </interval> 
   <apply>
     <cos/> 
     <ci> x </ci> 
   </apply> 
     </apply> 
     <div>
       Text in the last DIV.
     </div>
   </div>
     
JavaScript:
  var main = document.getElementById('doc');
  var elem = document.createElementNS('http://zvon.org/namespaces/test', 'zvon:temp');
  main.appendChild(elem);
  var output = main.getElementsByTagNameNS('http://zvon.org/namespaces/test', 'zvon:temp')[0].nodeName;
Output:
desired your browser
zvon:name