Java XML Node Parse parseProperties(Node doc)

Here you can find the source of parseProperties(Node doc)

Description

Parse the childnodes of a node and look for <property> elements with attributes name and value.

License

Apache License

Parameter

Parameter Description
n the XML node

Return

the parsed properties

Declaration

@Deprecated
public static Map<String, String> parseProperties(Node doc) 

Method Source Code

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

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

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

public class Main {
    /**//from  w  ww . j  a  va  2  s. c  o m
     * Parse the childnodes of a node and look for &lt;property&gt; elements with attributes name and value.
     * Example:
     * &lt;node&gt;
     *    &lt;property name='n' value='v'/&gt;
     * &lt;node/&gt;
     * @param n the XML node
     * @return the parsed properties
     * @deprecated Use XMLHelper.parseProperties( Node doc ) instead
     */
    @Deprecated
    public static Map<String, String> parseProperties(Node doc) {
        NodeList propertyNodes = doc.getChildNodes();
        Map<String, String> properties = new HashMap<String, String>();

        for (int i = 0; i < propertyNodes.getLength(); i++) {
            Node node = propertyNodes.item(i);

            if (node.getNodeName().equals("property")) {
                String key = node.getAttributes().getNamedItem("name").getNodeValue();
                String value = node.getAttributes().getNamedItem("value").getNodeValue();

                properties.put(key, value);
            }
        }

        return properties;
    }
}

Related

  1. parseList(Node node)
  2. parseModule(Node module, PrintWriter out)
  3. parseOptionNode(Node node)
  4. parseOptionString(Node node)
  5. parsePairFirst(Node node)
  6. parseProtoypes(Node module, Node iFace, PrintWriter out)
  7. parsePseudoHTML(Node e, StringBuffer html)
  8. parseSpelling(Node spelling)
  9. parseStringIdList(Node e)