Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Node; import org.w3c.dom.NodeList; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class Main { public static Map<String, String> getChildElementNodesMap(Node node) { if (node == null) { return null; } Map<String, String> map = new ConcurrentHashMap<>(); NodeList nodeList = node.getChildNodes(); if (nodeList != null && nodeList.getLength() > 0) { for (int i = 0; i < nodeList.getLength(); i++) { Node item = nodeList.item(i); if (item != null && item.getNodeType() == Node.ELEMENT_NODE) { map.put(item.getNodeName(), item.getTextContent().trim()); } } } return map; } }