Java Utililty Methods XML Attribute Load

List of utility methods to do XML Attribute Load

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

Description

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

Method

HashMap getAllAttributes(Element e)
get All Attributes
HashMap<String, String> m = new HashMap<>();
NamedNodeMap nnm = e.getAttributes();
for (int i = 0; i < nnm.getLength(); i++) {
 m.put(nnm.item(i).getNodeName(), nnm.item(i).getNodeValue());
return m;
Map getAllAttributes(Element elem, String name)
Get the attribute values of a given name/value pair for the first XML org.w3c.dom.Element of given name.
Map<String, String> attributes = new TreeMap<String, String>();
NodeList nodeList = elem.getElementsByTagName(name);
int length = nodeList.getLength();
for (int n = 0; n < length; ++n) {
 attributes.put(((Element) nodeList.item(n)).getAttribute("name"),
 ((Element) nodeList.item(n)).getAttribute("value"));
return attributes;
...
ArrayList getAllAttributes(Element element)
Get all attributes of the specified element
final NamedNodeMap nodeMap = element.getAttributes();
final ArrayList<Attr> result = new ArrayList<Attr>();
for (int i = 0; i < nodeMap.getLength(); i++)
 result.add((Attr) nodeMap.item(i));
return result;
HashMap getAllAttributes(Node node)
get All Attributes
HashMap<String, String> attributes = new HashMap<String, String>();
NamedNodeMap attr = node.getAttributes();
for (int j = 0; j < attr.getLength(); j++) {
 attributes.put(attr.item(j).getNodeName(), attr.item(j).getNodeValue());
return attributes;
Map getAllAttributes(Node node)
Returns a map of all node's attributes.
HashMap<String, String> attrs = new HashMap<String, String>();
NamedNodeMap nmm = node.getAttributes();
for (int j = 0; j < nmm.getLength(); j++) {
 Node attribute = nmm.item(j);
 if (attribute.getNodeType() != Node.ATTRIBUTE_NODE) {
 continue;
 attrs.put(attribute.getNodeName(), attribute.getNodeValue());
...
Map getAllAttributesAsMap(@Nullable final Element aSrcNode)
get All Attributes As Map
if (aSrcNode != null) {
 final NamedNodeMap aNNM = aSrcNode.getAttributes();
 if (aNNM != null) {
 final Map<String, String> aMap = new LinkedHashMap<String, String>(aNNM.getLength());
 final int nMax = aNNM.getLength();
 for (int i = 0; i < nMax; ++i) {
 final Attr aAttr = (Attr) aNNM.item(i);
 aMap.put(aAttr.getName(), aAttr.getValue());
...
void getAllAttrs(Element parent, String name, List lst)
get All Attrs
for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
 if (child.getNodeType() == Node.ELEMENT_NODE) {
 getAllAttrValueByName(child, name);
 List<String> tmp = getAllAttrValueByName(child, name);
 if (tmp != null) {
 lst.addAll(tmp);
 } else {
 getAllAttrs((Element) child, name, lst);
...
List getAllAttrValueByName(Node item, String name)
get All Attr Value By Name
List<String> lst = null;
NamedNodeMap attributes = item.getAttributes();
int numAttrs = attributes.getLength();
for (int i = 0; i < numAttrs; i++) {
 Attr attr = (Attr) attributes.item(i);
 String attrName = attr.getNodeName();
 if (name.equals(attrName)) {
 if (lst == null) {
...
String getAllElementAttributes(Element element)
get All Element Attributes
return getElementAttributes(element, new ArrayList<String>());
List getAllElementsWithAttrId(final Element element, final String namespace)
get All Elements With Attr Id
List<Element> list = new LinkedList<Element>();
if (elementHasId(element, namespace)) {
 list.add(element);
NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
 Node child = children.item(i);
 if (child instanceof Element == false) {
...


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