Java XML Element Check isTextOnly(final Element element)

Here you can find the source of isTextOnly(final Element element)

Description

is Text Only

License

Open Source License

Declaration

public static boolean isTextOnly(final Element element) 

Method Source Code

//package com.java2s;
/*//from   w  w  w .  j  a v  a2 s. c  o m
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., and individual contributors as indicated
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

public class Main {
    public static boolean isTextOnly(final Element element) {
        boolean isTextOnly = true;
        final NodeList nodeList = element.getChildNodes();
        for (int i = 0; i < nodeList.getLength() && isTextOnly; i++) {
            if (Element.class.isAssignableFrom(nodeList.item(i).getClass())) {
                isTextOnly = false;
            }
        }
        return isTextOnly;
    }
}

Related

  1. isSetPrefixBeforeStartElement( XMLStreamWriter writer)
  2. isSetPrefixBeforeStartElement(XMLStreamWriter writer)
  3. isStartElement(final XMLStreamReader reader)
  4. isStartElement(XMLStreamReader xmlRdr, String tagName)
  5. isTableNodes(Element e)
  6. isTrue(Element el, String tagName, boolean defaultResult)
  7. isUIParameter(Element ele)
  8. isUnder5_6(Element root)
  9. isXmlElementChoice(Field f, String xmlElementName)