Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.*;

public class Main {

    public static List<String> getChildNode(String xmlString, String node) {
        List<String> list = new ArrayList<String>();

        int start = 0, end = 0;
        do {
            start = xmlString.indexOf("<" + node + ">", start);
            end = xmlString.indexOf("</" + node + ">", end);
            if (start == -1 || end == -1) {
                break;
            }
            end += node.length() + 3;

            String subStr = xmlString.substring(start, end);
            start += 1;
            subStr = subStr.replace("<![CDATA[", "").replace("]]>", "");
            list.add(subStr);
        } while (true);
        return list;
    }
}