Changeset 3466


Ignore:
Timestamp:
2002-10-16T09:22:25+13:00 (22 years ago)
Author:
kjdon
Message:

add new method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java

    r3362 r3466  
    294294    return p;
    295295    }
     296
     297    /** returns the element parent/node_name[@attribute_name='attribute_value']
     298     */
     299    public static Element getNamedElement(Element parent, String node_name,
     300                      String attribute_name,
     301                      String attribute_value) {
     302
     303    NodeList children = parent.getChildNodes();
     304    for (int i=0; i<children.getLength(); i++) {
     305        Node child = children.item(i);
     306        if (child.getNodeName().equals(node_name)) {
     307        if (((Element)child).getAttribute(attribute_name).equals(attribute_value))
     308            return (Element)child;
     309        }
     310    }
     311    // not found
     312    return null;
     313    }
    296314}
Note: See TracChangeset for help on using the changeset viewer.