Java XML Node Text Value getFirstExtensionNodeFromWorkingSet(Node extensionsNode, String workingSetName)

Here you can find the source of getFirstExtensionNodeFromWorkingSet(Node extensionsNode, String workingSetName)

Description

Returns first node after the comment node with working set name

License

Apache License

Parameter

Parameter Description
extensionsNode extension node
workingSetName name of working set

Declaration

private static Node getFirstExtensionNodeFromWorkingSet(Node extensionsNode, String workingSetName) 

Method Source Code

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

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

public class Main {
    /**/*from w  w  w  .jav  a2s .  c o m*/
     * Returns first node after the comment node with working set name
     * 
     * @param extensionsNode
     *            extension node
     * @param workingSetName
     *            name of working set
     */
    private static Node getFirstExtensionNodeFromWorkingSet(Node extensionsNode, String workingSetName) {
        final String extensionTag = "extension";
        final String commentTag = "#comment";
        Node child;
        NodeList nodes = extensionsNode.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            child = nodes.item(i);
            if (commentTag.equals(child.getNodeName()) && workingSetName.equals(child.getNodeValue()))
                for (int j = i; j < nodes.getLength(); j++) {
                    child = nodes.item(j);
                    if (extensionTag.equals(child.getNodeName()))
                        return child;
                }
        }
        return null;
    }
}

Related

  1. getContentText(Node n)
  2. getDescendentText(Node node, String name)
  3. getDirectText(org.w3c.dom.Element node)
  4. getElementText(Node elem)
  5. getFirstExtensionNode(Node extensionsNode)
  6. getFirstLevelTextContent(Node node)
  7. getFirstSubElementsInnerText(Node element, String subElementName)
  8. getInnerXmlText(Node xmlNode)
  9. getNamedItemText(NamedNodeMap map, String name)