ZVON > References > DOM2 Reference

setNamedItemNS (method )

Owning interface and usage:  
NamedNodeMap.setNamedItemNS(arg)

Member of these other interfaces:  
none

Description:  
Adds a node using its namespaceURI and localName.

Parameters:  
Node arg  -  A node to store in this map.

Returns:  
Node -  If the new Node replaces an existing node the replaced Node is returned, otherwise null is returned.

Exceptions:  
DOMException WRONG_DOCUMENT_ERR
Raised if arg was created from a different document than the one that created this map.
DOMException NO_MODIFICATION_ALLOWED_ERR
Raised if this map is readonly.
DOMException INUSE_ATTRIBUTE_ERR
Raised if arg is an Attr that is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.
DOMException HIERARCHY_REQUEST_ERR
Raised if an attempt is made to add a node doesn't belong in this NamedNodeMap.

Note:  
If a node with that namespace URI and that local name is already present in this map, it is replaced by the new one. HTML-only DOM implementations do not need to implement this method.


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 attrNode = document.getElementById('doc').attributes;
  var attr = document.createAttributeNS('http://zvon.org/namespaces/test', 'zvon:temp');
  attr.value = 'temporary';
  attrNode.setNamedItemNS(attr);
  var output = attrNode.getNamedItemNS('http://zvon.org/namespaces/test', 'zvon:temp').nodeValue;
Output:
desired your browser
temporary



_____________________________________________
Reference Search | Sitemap | XML Glossary       ZVON | Systinet




Related sites:
  • dotNet Slackers - Your latest resource for ASP.NET
  • Dotnet Spider - Outsourcing and Offshore software development in India
  • XML - Xselerator, XSL Editor, BizTalk Utilities, XML Tutorials, Learn XML
  • Planet Source Code - The largest public source code database on the Internet
answering service water softener MSN Alojamiento Web UNLIMITED Web Hosting by HostDepartment
VoIP Internettelefonie Hosted Exchange, SDSL VoIP Internettelefonie AT VoIP Internettelefonie DE