Java XML NodeList parseSwitcherConfigs(NodeList switcherConfigNodes)

Here you can find the source of parseSwitcherConfigs(NodeList switcherConfigNodes)

Description

parse Switcher Configs

License

Apache License

Declaration

private static Map<String, String> parseSwitcherConfigs(NodeList switcherConfigNodes) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.NamedNodeMap;

import org.w3c.dom.NodeList;

import java.util.HashMap;

import java.util.Map;

public class Main {
    private static Map<String, String> parseSwitcherConfigs(NodeList switcherConfigNodes) {
        Map<String, String> configs = new HashMap<>();
        for (int i = 0; i < switcherConfigNodes.getLength(); ++i) {
            NamedNodeMap attributes = switcherConfigNodes.item(i).getAttributes();
            if (attributes != null) {
                String[] keyValue = parseConfigAttr(attributes);
                configs.put(keyValue[0], keyValue[1]);
            }/*from w  ww. j ava 2s.co m*/
        }

        return configs;
    }

    private static String[] parseConfigAttr(NamedNodeMap attributes) {
        String key = attributes.getNamedItem("key").getTextContent();
        String value = attributes.getNamedItem("value").getTextContent();
        return new String[] { key, value };
    }
}

Related

  1. listOf(final NodeList nodeList)
  2. mapNodeList(NodeList nodeList)
  3. mergeTextContent(final NodeList nodes)
  4. mergeTextContent(NodeList nodes)
  5. parserXml(NodeList employees, Class class_type)
  6. parseSwitchers(NodeList switcherNodes)
  7. parseWidget(NodeList widgetList)
  8. prettyPrintLoop(NodeList nodes, StringBuilder string, String indentation)
  9. printNode(NodeList nodeList, int level)