Here you can find the source of getAttribute(Node node, String name)
Parameter | Description |
---|---|
node | the node whose attribute we'd like to extract. |
name | the name of the attribute to extract. |
public static String getAttribute(Node node, String name)
//package com.java2s; /*//from w w w. ja va 2 s .c o m * Jitsi, the OpenSource Java VoIP and Instant Messaging client. * * Distributable under LGPL license. * See terms of license at gnu.org. */ import org.w3c.dom.*; public class Main { /** * Extracts from node the attribute with the specified name. * @param node the node whose attribute we'd like to extract. * @param name the name of the attribute to extract. * @return a String containing the trimmed value of the attribute or null * if no such attribute exists */ public static String getAttribute(Node node, String name) { if (node == null) return null; Node attribute = node.getAttributes().getNamedItem(name); return (attribute == null) ? null : attribute.getNodeValue().trim(); } }