Java XML Element to String getStringProperty(Element properties, String name)

Here you can find the source of getStringProperty(Element properties, String name)

Description

get String Property

License

Open Source License

Declaration

public static String getStringProperty(Element properties, String name) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

public class Main {
    public static final String PROPERTY_NODE = "property";
    public static final String NAME_ATTR = "name";
    public static final String STRING_ATTR = "stringvalue";

    public static String getStringProperty(Element properties, String name) {
        return getPropertyNode(properties, name).getAttributes().getNamedItem(STRING_ATTR).getNodeValue();
    }/*w ww. j a va2  s.  co m*/

    public static Element getPropertyNode(Element properties, String name) {
        NodeList nodeList = properties.getElementsByTagName(PROPERTY_NODE);
        for (int i = 0; i < nodeList.getLength(); i++) {
            Element element = (Element) nodeList.item(i);
            if (name.equals(element.getAttributes().getNamedItem(NAME_ATTR).getNodeValue())) {
                return element;
            }
        }
        return null;
    }
}

Related

  1. getString(Element xmlElement)
  2. getString(final Element element)
  3. getStringByTagName(Element element, String tag)
  4. getStringFromParagraphElement(Element element)
  5. getStringOptionsList(final Element configuration, final String optionPrefix, final String option)
  6. getStringRepresentation(Element element)
  7. getStringValue(Element el)
  8. getStringValue(Element ele, String tagName)
  9. getStringValue(Element element, String tagName)