Package io.lumify.palantir.dataImport.util

Source Code of io.lumify.palantir.dataImport.util.XmlUtil

package io.lumify.palantir.dataImport.util;

import io.lumify.core.exception.LumifyException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class XmlUtil {
    public static Element getChildByTagName(Element element, String tagName) {
        Element result = null;
        NodeList childNodes = element.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node n = childNodes.item(i);
            if (!(n instanceof Element)) {
                continue;
            }
            if (((Element) n).getTagName().equals(tagName)) {
                if (result != null) {
                    throw new LumifyException("Too many elements with tag name " + tagName);
                }
                result = (Element) n;
            }
        }
        return result;
    }
}
TOP

Related Classes of io.lumify.palantir.dataImport.util.XmlUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.