Java XML Node Save xmlSelectNodes0(List list, Node node, String path[], int n)

Here you can find the source of xmlSelectNodes0(List list, Node node, String path[], int n)

Description

xml Select Nodes

License

Open Source License

Declaration

private static void xmlSelectNodes0(List list, Node node, String path[], int n) 

Method Source Code

//package com.java2s;
/*/*  w  ww.ja va 2 s .  c o m*/
 *   SoftSqueeze Copyright (c) 2004 Richard Titmuss
 *
 *   This file is part of SoftSqueeze.
 *
 *   SoftSqueeze is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   SoftSqueeze is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with SoftSqueeze; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

import java.util.List;

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

public class Main {
    private static void xmlSelectNodes0(List list, Node node, String path[], int n) {
        if (n == path.length) {
            list.add(node);
            return;
        }

        if (path[n].equals("..")) {
            xmlSelectNodes0(list, node.getParentNode(), path, n + 1);
            return;
        }

        NodeList kids = node.getChildNodes();
        for (int i = 0; i < kids.getLength(); i++) {
            Node kid = kids.item(i);

            if (kid.getNodeName().equals(path[n]))
                xmlSelectNodes0(list, kid, path, n + 1);
        }
    }
}

Related

  1. writeToString(Node node)
  2. writeXml(final Node node)
  3. writeXMLwalkTree(Node node, int indent, PrintWriter out)
  4. writeXMLwithXALAN(final Writer writer, final Node node, final String xmlEncoding)
  5. writeXMLwithXALAN(final Writer writer, final Node node, final String xmlEncoding)
  6. xmltostring(String indent, Node node)