public static Map<String, Object> toMap(XmlReaders readers){
        Node root = readers.getNode("xml");
        if (root == null){
            return Collections.emptyMap();
        }
        NodeList children = root.getChildNodes();
        if (children.getLength() == 0){
            return Collections.emptyMap();
        }
        Map<String, Object> data = new HashMap<>(children.getLength());
        Node n;
        for (int i = 0; i<children.getLength(); i++){
            n = children.item(i);
            data.put(n.getNodeName(), n.getTextContent());
        }
        return data;
    }
public static Map < String , Object > toMap ( XmlReaders readers ) { Node root = readers . getNode ( "xml" ) ; if ( root == null ) { return Collections . emptyMap ( ) ; } NodeList children = root . getChildNodes ( ) ; if ( children . getLength ( ) == 0 ) { return Collections . emptyMap ( ) ; } Map < String , Object > data = new HashMap < > ( children . getLength ( ) ) ; Node n ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { n = children . item ( i ) ; data . put ( n . getNodeName ( ) , n . getTextContent ( ) ) ; } return data ; }
转换微信XML为Map(仅支持2级)
@param readers xmlReaders
@return Map对象