Java Utililty Methods XML Attribute Remove

List of utility methods to do XML Attribute Remove

  1. HOME
  2. Java
  3. X
  4. XML Attribute Remove

Description

The list of methods to do XML Attribute Remove are organized into topic(s).

Method

void removeAllAttributes(Element element)
remove All Attributes
NamedNodeMap attrs = element.getAttributes();
int attrCount = attrs.getLength();
for (int i = attrCount - 1; i >= 0; --i) {
 Attr attr = (Attr) attrs.item(i);
 attrs.removeNamedItemNS(attr.getNamespaceURI(), attr.getLocalName());
void removeAllAttributes(Element element)
remove All Attributes
Vector<String> names = new Vector<String>();
int length = element.getAttributes().getLength();
NamedNodeMap atts = element.getAttributes();
for (int i = 0; i < length; names.add(atts.item(i).getLocalName()), i++)
 ;
for (String name : names)
 element.removeAttribute(name);
void removeAllAttributes(Element element)
Remove all attribute from the specified element
final NamedNodeMap nodeMap = element.getAttributes();
for (int i = 0; i < nodeMap.getLength(); i++)
 element.removeAttribute(nodeMap.item(i).getNodeName());
void removeAllAttributes(Node node, String attrName)
remove All Attributes
NamedNodeMap attrs = node.getAttributes();
if (attrs != null && attrs.getNamedItem(attrName) != null) {
 attrs.removeNamedItem(attrName);
NodeList list = node.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
 Node childNode = list.item(i);
 removeAllAttributes(childNode, attrName);
...
void removeAllSubNodesExceptAttributes(Node n)
remove All Sub Nodes Except Attributes
NodeList childNodes = n.getChildNodes();
List<Node> childNodesToRemove = new ArrayList<Node>();
for (int i = 0; i < childNodes.getLength(); i++) {
 Node c = childNodes.item(i);
 if (c.getNodeType() != Node.ATTRIBUTE_NODE) {
 childNodesToRemove.add(c);
for (Node c : childNodesToRemove) {
 n.removeChild(c);
void removeAttribute(Element elem, String name)
Oracle 10i does not allow to remove an attribute that does not exist.
try {
 elem.removeAttribute(name);
} catch (Exception e) {
void removeAttribute(Element element, String name)
Remove an attribute from the specified element
element.removeAttribute(name);
void removeAttribute(final Attr attributeNode)
remove Attribute
if (attributeNode == null) {
 return;
final Element owner = attributeNode.getOwnerElement();
if (owner == null) {
 return;
owner.removeAttributeNode(attributeNode);
...
void removeAttribute(final Node iNode, final String iAttributeName)
This method removes the specified attribute from the specified node.
NamedNodeMap attrList = iNode.getAttributes();
attrList.removeNamedItem(iAttributeName);
void removeAttribute(final Node node, final String name)
remove Attribute
if (node != null) {
 final NamedNodeMap namedNodeMap = node.getAttributes();
 if (namedNodeMap != null) {
 namedNodeMap.removeNamedItem(name);


AltStyle によって変換されたページ (->オリジナル) /