I would suggest using Element.setAttribute(java.lang.String name, java.lang.String value) as an alternative.
- Rick Bullotta Lighthammer Software (www.lighthammer.com) -----Original Message----- From: Becker, Matthias [mailto:[EMAIL PROTECTED] Sent: Monday, February 12, 2001 09:28 To: '[EMAIL PROTECTED]' Subject: Append Attribute to each Element-Node Hi, I try to append one Attribute to each Element in an document. If I try something like this: NodeList Elements = document.getElementByTagName("*"); for (int i=0; i<Elements.getLength(); i++){ Attr a = xmldoc.createAttribute("id"); a.setNodeValue(i); Elements.item(i).append.appendChild((Node) a); } I get the following error. org.w3c.dom.DOMException: DOM006 Hierarchy request error at org.apache.xerces.dom.ChildAndParentNode.internalInsertBefore (ChildAndParentNode.java:379) at org.apache.xerces.dom.ChildAndParentNode.insertBefore (ChildAndParentNode.java:296) at org.apache.xerces.dom.NodeImpl.appendChild (NodeImpl.java:212) at parsertest.<init>(parsertest.java:36) at parsertest.main(parsertest.java:44) Exception in thread "main" Where do I make the mistake? I think this one should be done easy. It would be easy if it get an List of Elements instead of a NodeList, because an Element as the Method setAttribute(). But a Node doesn't have this Methode. How can I do this anyway. Thanks in advance Matthias --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
