import java.io.*;
class ren{
String[] data=new String[5000];
String[] title=new String[5000];
String[] content=new String[5000];
String[] author=new String[5000];
int[] point=new int[5000];
int p1,p2;
String str;
int s,datanumber,xmlnumber;
public static void main(String [] args) {
ren test=new ren();
}
ren(){
readfile("xml.txt");
for(s=1;s<datanumber+1;s++){
p1=data[s].indexOf("<title>");
p2=data[s].indexOf("</title>");
title[s]=data[s].substring(p1+7,p2);
p1=data[s].indexOf("<point>");
p2=data[s].indexOf("</point>");
str=data[s].substring(p1+7,p2);
point[s]=Integer.parseInt(str);
p1=data[s].indexOf("<content>");
p2=data[s].indexOf("</content>");
content[s]=data[s].substring(p1+9,p2);
p1=data[s].indexOf("<author>");
p2=data[s].indexOf("</author>");
author[s]=data[s].substring(p1+8,p2);
System.out.println(author[s]);
}
}
void readfile(String file){
String str;
BufferedReader br;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"SJIS"));
while((str = br.readLine()) != null) {
s=s+1;
data[s]=str;
}
br.close();
} catch (IOException e) {System.out.println(e);}
datanumber=s;
}
}
最終更新:2011年06月30日 15:06