Java Utililty Methods XML Attribute Read

List of utility methods to do XML Attribute Read

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

Description

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

Method

long getLong(Node xmlNode, String attributeLabel)
get Long
return Long.parseLong(xmlNode.getAttributes().getNamedItem(attributeLabel).getNodeValue());
long getLong(String attrName, Map runtimeAttributes, Node docElement)
Get a long value.
String stringValue = getStringValue(attrName, runtimeAttributes, docElement);
if (stringValue != null) {
 try {
 return Long.parseLong(stringValue);
 } catch (NumberFormatException e) {
throw new RuntimeException(
...
Long getLongAttribute(NamedNodeMap namedNodeMap, String name)
get Long Attribute
String value = getAttribute(namedNodeMap, name);
if (value == null) {
 return null;
} else {
 return Long.valueOf(value);
Long getLongAttribute(String name, Element el)
Gets the value of the DOM element's attribute with the given name as a Long, or null if the value is not a long.
return stringToLong(getAttribute(name, el));
String getNameAttribute(final Node aNode)
Retrieves the value of the name attribute of the supplied Node.
return getNamedAttribute(aNode, NAME_ATTRIBUTE);
String getNamedAttribute(final Node aNode, final String attributeName)
get Named Attribute
if (aNode == null) {
 return null;
final NamedNodeMap attributes = aNode.getAttributes();
if (attributes != null) {
 final Node nameNode = attributes.getNamedItem(attributeName);
 if (nameNode != null) {
 return nameNode.getNodeValue().trim();
...
Attr getNewAttribute(Element element, String name)
get New Attribute
String safeName = name.replaceAll("\\$", "::");
return element.getOwnerDocument().createAttribute(safeName);
String getNSPrefixFromNSAttr(Attr a)
Fetch the non-null namespace prefix from a Attr that declares a namespace.
assert a != null;
assert isNSAttribute(a);
if (a.getPrefix() == null) {
 return "";
return a.getName().substring(a.getPrefix().length() + 1);
String getNullableAttribute(final Element node, final String attributeName)
Get the attribute value under the specified name from the given element.
if (node.hasAttribute(attributeName)) {
 return node.getAttribute(attributeName);
return null;
String getNullSafe(NamedNodeMap attr, String key)
Get the node value of the attribute key from the set attr .
Node node = attr.getNamedItem(key);
return node != null ? node.getNodeValue() : null;


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