ZVON > References > DOM2 Reference

setAttributeNodeNS (method )

Owning interface and usage:  
Element.setAttributeNodeNS(newAttr)

Member of these other interfaces:  
none

Description:  
Adds a new attribute.

Parameters:  
Attr newAttr  -  The Attr node to add to the attribute list.

Returns:  
Attr -  If the newAttr attribute replaces an existing attribute with the same local name and namespace URI, the replaced Attr node is returned, otherwise null is returned.

Exceptions:  
DOMException WRONG_DOCUMENT_ERR
Raised if newAttr was created from a different document than the one that created the element.
DOMException NO_MODIFICATION_ALLOWED_ERR
Raised if this node is readonly.
DOMException INUSE_ATTRIBUTE_ERR
Raised if newAttr is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.

Note:  
If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one.


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 elem = document.getElementById('doc');
  var attr = document.createAttributeNS('http://zvon.org/namespaces/test', 'zvon:temp');
  attr.value = 'temporary';
  elem.setAttributeNodeNS(attr);
  var output = elem.getAttributeNodeNS('http://zvon.org/namespaces/test', 'zvon:temp').value;
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