Example usage for org.jdom2 Element getChildText

List of usage examples for org.jdom2 Element getChildText

Introduction

In this page you can find the example usage for org.jdom2 Element getChildText.

Prototype

public String getChildText(final String cname, final Namespace ns) 

Source Link

Document

Returns the textual content of the named child element, or null if there's no such child.

Usage

From source file:XMLReader.ReadUsersXML.java

License:Open Source License

public static User ReadUser(String usuario, String pass, String xmlSource) {
    User user = null;//from   www. j  a va 2 s  . co m

    try {
        Element rootNode = builder.build(xmlSource).getRootElement();
        List<Element> usersList = rootNode.getChildren("user", ns);

        for (Element e : usersList) {
            if (e.getChildText("usuario", ns).equals(usuario) && e.getChildText("password", ns).equals(pass)) {
                user = new User(e, ns);
                break;
            }
        }
    } catch (IOException io) {
        System.out.println(io.getMessage());
    } catch (JDOMException jdomex) {
        System.out.println(jdomex.getMessage());
    }

    return user;
}