Java XML NodeList parseWidget(NodeList widgetList)

Here you can find the source of parseWidget(NodeList widgetList)

Description

parse Widget

License

Open Source License

Declaration

public static Map parseWidget(NodeList widgetList) 

Method Source Code


//package com.java2s;

import java.util.HashMap;
import java.util.Map;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static Map parseWidget(NodeList widgetList) {
        Map map = new HashMap();
        try {/*w ww  .  j a  va  2 s.c om*/
            for (int i = 0; i < widgetList.getLength(); i++) {
                Node widget = widgetList.item(i);
                if (widget.getNodeName().equals("widget")) {
                    String id = widget.getAttributes().getNamedItem("id").getTextContent();
                    Map attrMap = parseAttribute(widget.getChildNodes());
                    map.put(id, attrMap);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return map;
    }

    public static Map parseAttribute(NodeList abtList) {
        Map map = new HashMap();
        try {
            for (int i = 0; i < abtList.getLength(); i++) {
                Node abt = abtList.item(i);
                if (abt.getNodeType() == 1) {
                    map.put(abt.getNodeName(), abt.getTextContent());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return map;
    }
}

Related

  1. mergeTextContent(final NodeList nodes)
  2. mergeTextContent(NodeList nodes)
  3. parserXml(NodeList employees, Class class_type)
  4. parseSwitcherConfigs(NodeList switcherConfigNodes)
  5. parseSwitchers(NodeList switcherNodes)
  6. prettyPrintLoop(NodeList nodes, StringBuilder string, String indentation)
  7. printNode(NodeList nodeList, int level)
  8. printNodeList(NodeList nodes)
  9. printNodeTypes(NodeList rows)