アットウィキロゴ

がめ0205x

import java.io.*;

class game0318{

String str;
String bun;
String article[]=new String[100];
String title[]=new String[100];
String des[]=new String[100];
String link[]=new String[100];
int num;
int k,s;

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

game0318(){

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

k=bun.length();

makearticle();

System.out.println(num);

for (s=1;s<num+1;s++){
title[s]=makedata(article[s],"title");
des[s]=makedata(article[s],"description");
link[s]=makedata(article[s],"link");
}


for (s=1;s<num+1;s++){
System.out.println(link[s]);
}



}

String makedata(String doc,String you){
String sx1,sx2;
int x1,x2;
int lp1;
int lp2;
sx1="<"+you+">";
sx2="</"+you+">";
lp1=sx1.length();
lp2=sx2.length();
x1=doc.indexOf(sx1);
x2=doc.indexOf(sx2);
return doc.substring(x1+lp1,x2);
}


void makearticle(){
int point,x,n;
point=0;
x=bun.indexOf("<item");
n=0;
while(x>0){
n=n+1;
article[n]=makearticle(bun,point);
point=checkpoint(bun,point);
x=bun.indexOf("<item",point);
}
num=n;
}
int checkpoint(String bun,int point){
String sx2;
int x2;
int lp2;
sx2="</item>";
lp2=sx2.length();
x2=bun.indexOf(sx2,point);
return x2+lp2;
}


String makearticle(String bun,int point){
String sx1,sx2;
int x1,x2;
int lp1;
int lp2;
sx1="<item";
sx2="</item>";
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日 12:22