648540858
2024-03-12 cb5afce55eec2badda5090c27564e43f201ac9af
src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
@@ -78,6 +78,50 @@
    }
    /**
     * 获取element对象的text的值
     *
     * @param em  节点的对象
     * @param tag 节点的tag
     * @return 节点
     */
    public static Double getDouble(Element em, String tag) {
        if (null == em) {
            return null;
        }
        Element e = em.element(tag);
        if (null == e) {
            return null;
        }
        String text = e.getText().trim();
        if (ObjectUtils.isEmpty(text) || !NumberUtils.isParsable(text)) {
            return null;
        }
        return Double.parseDouble(text);
    }
    /**
     * 获取element对象的text的值
     *
     * @param em  节点的对象
     * @param tag 节点的tag
     * @return 节点
     */
    public static Integer getInteger(Element em, String tag) {
        if (null == em) {
            return null;
        }
        Element e = em.element(tag);
        if (null == e) {
            return null;
        }
        String text = e.getText().trim();
        if (ObjectUtils.isEmpty(text) || !NumberUtils.isParsable(text)) {
            return null;
        }
        return Integer.parseInt(text);
    }
    /**
     * 递归解析xml节点,适用于 多节点数据
     *
     * @param node     node