Java XML Element Get Value getTextContentOfElements(Element elem, String tagName)

Here you can find the source of getTextContentOfElements(Element elem, String tagName)

Description

get Text Content Of Elements

License

Apache License

Declaration

public static List<String> getTextContentOfElements(Element elem, String tagName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

import java.util.List;

import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class Main {
    public static List<String> getTextContentOfElements(Element elem, String tagName) {
        List<String> result = new ArrayList<String>();
        NodeList inputElems = elem.getElementsByTagName(tagName);
        for (int i = 0; i < inputElems.getLength(); i++) {
            Element childElem = (Element) inputElems.item(i);
            result.add(childElem.getTextContent());
        }/*from w w w  . j  a  v a2s .  c  o m*/
        return result;
    }
}

Related

  1. getTextContent(Element element)
  2. getTextContent(Element element)
  3. getTextContent(Element element)
  4. getTextContentFromFirstElementByTagName(Element element, String tagName)
  5. getTextContentOfElement(Element elem, String tagName, boolean required)
  6. getTextContents(Element e)
  7. getTextData(Element element)
  8. getTextElementValue(Element ele)
  9. getTextFromFirstSubEleByName(Element element, String tagName)