dom4j解析XML 多层标签

引入dom4j.jar

创建文件:

Web/xml/cityChinese.xml

Web/xml/cityCode.xml

public static void main(String[] args) {
		int[] arr = new int[10];
		System.out.println("排序:");
		for (int i = 0; i < 10; i++) {
			arr[i] = (int) (Math.random()*20);
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		
		
		System.out.println("从大到小排序:");
		for (int i = 0; i < arr.length-1; i++) {
			for (int j = i+1; j < arr.length; j++) {
				while(arr[j] > arr[i]){
				int	temp = arr[i];
					arr[i] = arr[j];
					arr[j] = temp;
				}
			}
		}
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		
		System.out.println("最终排序:");
		for (int i = 0; i < arr.length/2; i++) {
			System.out.print(arr[i] + " ");
			System.out.print(arr[arr.length-i-1] + " ");
		}
		if(arr.length%2 != 0){
			System.out.println(arr[arr.length/2]);
		}
	}

你可能感兴趣的:(JAVA--xml解析)