Java XML Element to String getString(Element root, String name)

Here you can find the source of getString(Element root, String name)

Description

get String

License

Open Source License

Declaration

public static String getString(Element root, String name) 

Method Source Code

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

import org.w3c.dom.Element;

public class Main {
    public static String getString(Element root, String name) {
        try {// w  w w  .  java 2s. c  o  m
            Element e = (Element) root.getElementsByTagName(name).item(0);
            return e.getTextContent();
        } catch (Exception e) {
            System.err.println("Failed to parse String for tag " + name + "!");
        }
        return "NOT SET";
    }
}

Related

  1. getNamedElemXml(Element parent, String elementName)
  2. getString(Element el, String label)
  3. getString(Element element)
  4. getString(Element element, String expr)
  5. getString(Element element, String name, String def)
  6. getString(Element xmlElement)
  7. getString(final Element element)
  8. getStringByTagName(Element element, String tag)
  9. getStringFromParagraphElement(Element element)