Java XML First Child Element firstTextChild(Element el)

Here you can find the source of firstTextChild(Element el)

Description

first Text Child

License

Open Source License

Parameter

Parameter Description
el a parameter

Return

the first text child of an element, or null if it has none

Declaration

public static Text firstTextChild(Element el) 

Method Source Code

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

import org.w3c.dom.Element;

import org.w3c.dom.Node;

import org.w3c.dom.Text;

public class Main {
    /**//  w  w  w . j a v  a  2 s  . c o  m
     * @param el
     * @return the first text child of an element, or null  if it has none
     */
    public static Text firstTextChild(Element el) {
        Text text = null;
        for (int i = 0; i < el.getChildNodes().getLength(); i++) {
            Node n = el.getChildNodes().item(i);
            if (n instanceof Text)
                text = (Text) n;
        }
        return text;
    }
}

Related

  1. firstChildElement(Node node)
  2. firstChildNodeWithName(org.w3c.dom.Node node, String name)
  3. firstChildTextContent(Element element, String name)
  4. firstElementNodeChild(Node n)
  5. firstNamedChild(Element el, String lName)
  6. getDirectChild(Node fNode, String localName, String namespace)
  7. getDirectChild(Node fNode, String localName, String namespace)
  8. getDirectChildElement(Element p_rootElement, String p_elementName)
  9. getDirectChildElements(Element parent)