アットウィキロゴ

XML0201

import java.io.*;

class game0318{

String str;
String bun;
String title[]=new String[100];
int m,num;
int n1,n,k;
int t;
int lp;
String s,s1,s2,ss,se;
int x,x1,x2;
int point;
int chpoint;

public static void main(String [] args) {
        game0318 f=new game0318();
            }

game0318(){

str="test.xml";
  
inputdata(str);

k=bun.length();

s2="description";

point=0;
x=bun.indexOf(s2,point);
n=0;
while(x>0){
n=n+1;
title[n]=maketitle(bun,s2,point);
point=checkpoint(bun,s2,point);
x=bun.indexOf(s2,point);
System.out.println(title[n]);
}




}

int checkpoint(String bun,String str,int point){
String sx1,sx2;
int x1,x2;
int lp1;
int lp2;
sx1="<"+s2+">";
sx2="</"+s2+">";
lp1=sx1.length();
lp2=sx2.length();
x1=bun.indexOf(sx1,point);
x2=bun.indexOf(sx2,point);
return x2+lp2;
}


String maketitle(String bun,String str,int point){
String sx1,sx2;
int x1,x2;
int lp1;
int lp2;
sx1="<"+s2+">";
sx2="</"+s2+">";
lp1=sx1.length();
lp2=sx2.length();
x1=bun.indexOf(sx1,point);
x2=bun.indexOf(sx2,point);
return bun.substring(x1+lp1,x2);
}




void inputdata(String str){
int num;
int n;
String sp;
String data[]=new String[10000];  
n=0;
try {  
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("test.xml"), "UTF-8"));
while((sp = br.readLine()) != null) {  
data[n]=sp;
n=n+1;
}
br.close();
} catch (IOException e) {System.out.println(e);}
num=n;
bun="";
for (n=0;n<num;n++){
bun=bun+data[n];
}
}

}
最終更新:2011年03月26日 11:21