Changeset 14348 in josm for trunk


Ignore:
Timestamp:
2018-10-18T21:22:13+02:00 (6 years ago)
Author:
Don-vip
Message:

see #12726 - new XML util to get first child Element

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/XmlUtils.java

    r13901 r14348  
    1818
    1919import org.w3c.dom.Document;
     20import org.w3c.dom.Element;
     21import org.w3c.dom.Node;
     22import org.w3c.dom.NodeList;
    2023import org.xml.sax.InputSource;
    2124import org.xml.sax.SAXException;
     
    141144        return factory;
    142145    }
     146
     147    /**
     148     * Get the first child element
     149     * @param parent parent node
     150     * @return the first child element
     151     * @since 14348
     152     */
     153    public static Element getFirstChildElement(Node parent) {
     154        NodeList children = parent.getChildNodes();
     155        for (int i = 0; i < children.getLength(); i++) {
     156            Node child = children.item(i);
     157            if (child instanceof Element) {
     158                return (Element) child;
     159            }
     160        }
     161        return null;
     162    }
    143163}
Note: See TracChangeset for help on using the changeset viewer.