アットウィキロゴ

xmlれあでr

class xmlreader{
int s;  
String urlx;
String bun;    
int x[]=new int[1000];
int y[]=new int[1000];
int entry1[]=new int[100];
int entry2[]=new int[100];
int source1[]=new int[100];
int source2[]=new int[100];
String[] title=new String[100];
String[] author=new String[100];
String[] published=new String[100];
String[] content=new String[100];
String[] link=new String[100];  
int title1[]=new int[100];
int title2[]=new int[100];
int published1[]=new int[100];
int published2[]=new int[100];
int content1[]=new int[100];
int content2[]=new int[100];
int author1[]=new int[100];
int author2[]=new int[100];
String id[]=new String[100];
int category1[]=new int[100];
int category2[]=new int[100];
String category[]=new String[100];

String xml[]=new String[1000];  
int xmlnumber;
int articlenumber;
String str,v;

void makedata(){

getdata gd=new getdata();
gd.makedata(urlx);
bun=gd.bun;

startxml();

makecredit();

makeentry();

for(s=1;s<articlenumber+1;s++){
makesource(s);
}


for(s=1;s<articlenumber+1;s++){
maketitle(s);
makepublished(s);
makecontent(s);
makeauthor(s);
makelink(s);
makecategory(s);
}

zen();

for(s=1;s<articlenumber+1;s++){
content[s]=rev(content[s]);
title[s]=rev(title[s]);
link[s]=rev(link[s]);
}



}

void maketitle(int s){
int p1,p2,sx,x1,x2;
p1=entry1[s];
p2=source1[s];
for(sx=p1;sx<p2;sx++){
x1=xml[sx].indexOf("title type");
x2=xml[sx].indexOf("/title");
if(x2>-1)x1=-999;
if(x1>-1)title1[s]=sx;
if(x2>-1)title2[s]=sx;
}

}

void startxml(){

int s,mode,z;

s=1;
mode=0;
z=bun.indexOf("<");
x[1]=z;
while(mode<50){
z=bun.indexOf("<",z+1);
if(z>-1)s=s+1;
if(z>-1)x[s]=z;
if(z<0)mode=100;
}

s=1;
mode=0;
z=bun.indexOf(">");
y[1]=z;
while(mode<50){
z=bun.indexOf(">",z+1);
if(z>-1)s=s+1;
if(z>-1)y[s]=z;
if(z<0)mode=100;
}

xmlnumber=s;

}


void makecredit(){
int s,p1,p2;
for(s=1;s<xmlnumber+1;s++){
p1=x[s];
p2=y[s];
xml[s]=bun.substring(p1+1,p2);
}

}

void makeentry(){
int s,sx,p1,p2;
sx=0;
for (s=1;s<xmlnumber+1;s++){
p1=xml[s].indexOf("entry");
p2=xml[s].indexOf("/entry");
if(p2>-1)p1=-999;
if(p1>-1)sx=sx+1;
if(p1>-1)entry1[sx]=s;
if(p2>-1)entry2[sx]=s;
}

articlenumber=sx;
}

void makesource(int s){
int sx,p1,p2,x1,x2;
p1=entry1[s];
p2=entry2[s];
for(sx=p1;sx<p2+1;sx++){
x1=xml[sx].indexOf("source");
x2=xml[sx].indexOf("/source");
if(x2>-1)x1=-999;
if(x1>-1)source1[s]=sx;
if(x2>-1)source2[s]=sx;
}
}

void makepublished(int s){
int sx,p1,p2,x1,x2;
p1=entry1[s];
p2=source1[s];
for(sx=p1;sx<p2;sx++){
x1=xml[sx].indexOf("published");
x2=xml[sx].indexOf("/published");
if(x2>-1)x1=-999;
if(x1>-1)published1[s]=sx;
if(x2>-1)published2[s]=sx;
}
}

void makecategory(int s){
int sx,p1,p2,x1,x2;
p1=source1[s];
p2=source2[s];
for(sx=p1;sx<p2;sx++){
x1=xml[sx].indexOf("title");
x2=xml[sx].indexOf("/title");
if(x2>-1)x1=-999;
if(x1>-1)category1[s]=sx;
if(x2>-1)category2[s]=sx;
}
}




void makelink(int s){
int sx,p1,p2,x1,z;
String str;
p1=entry1[s];
p2=source1[s];
z=1;
for(sx=p1;sx<p2;sx++){
x1=xml[sx].indexOf("link");  
if(x1>-1)z=sx;
}
str=xml[z];
link[s]=str;
}

void makecontent(int s){
int sx,p1,p2,x1,x2;
p1=entry1[s];
p2=entry2[s];
for(sx=p1;sx<p2;sx++){
x1=xml[sx].indexOf("content");
x2=xml[sx].indexOf("/content");
if(x2>-1)x1=-999;
if(x1>-1)content1[s]=sx;
if(x2>-1)content2[s]=sx;
}

}

void makeauthor(int s){
int sx,p1,p2,x1,x2;
p1=entry1[s];
p2=entry2[s];
for(sx=p1;sx<p2+1;sx++){
x1=xml[sx].indexOf("name");
x2=xml[sx].indexOf("/name");
if(x2>-1)x1=-999;
if(x1>-1)author1[s]=sx;
if(x2>-1)author2[s]=sx;
}

}

void zen(){
int p1,p2;

for(s=1;s<articlenumber+1;s++){
p1=y[title1[s]];
p2=x[title2[s]];
title[s]=bun.substring(p1+1,p2);
}

for(s=1;s<articlenumber+1;s++){
p1=y[content1[s]];
p2=x[content2[s]];
content[s]=bun.substring(p1+1,p2);
}

for(s=1;s<articlenumber+1;s++){
p1=y[published1[s]];
p2=x[published2[s]];
published[s]=bun.substring(p1+1,p2);
}

for(s=1;s<articlenumber+1;s++){
p1=y[author1[s]];
p2=x[author2[s]];
author[s]=bun.substring(p1+1,p2);
}

for(s=1;s<articlenumber+1;s++){
p1=y[category1[s]];
p2=x[category2[s]];
category[s]=bun.substring(p1+1,p2);
}

for(s=1;s<articlenumber+1;s++){
p1=x[entry1[s]];
p2=y[entry1[s]];
str=bun.substring(p1+1,p2);
String[] x=str.split("=");
id[s]=x[1].substring(1,x[1].length()-1);
}


}

String rev(String str){
String z,str1,str2,str3,str4,str5,str6,str7,str8;
str1="<";
str2="&lt;";
str3=">";
str4="&gt;";
str5="&amp;gt;";
str6="&amp;lt;";

z=str.replace(str2,str1);
z=z.replace(str4,str3);  
z=z.replace(str6,str1);
z=z.replace(str5,str3);  
int p;
p=check(z);
while(p>50){
z=play(z);
p=check(z);
}

str7="'";
str8="&amp;#39;";

z=z.replace(str8,str7);

return z;
}

int check(String str){
int p,h,p1,p2;
String str1,str2;
str1="<";
str2=">";
p=100;
p1=str.indexOf(str1);
p2=str.indexOf(str2);
h=0;
if(p1<0)p=0;
if(p2<0)p=0;
return p;
}

String play(String str){
int p1,p2,px,zlong;
String r2[]=new String[100];
String str1,str2;
String x1,x2;
str1="<";
str2=">";
zlong=str.length();
p1=str.indexOf(str1);
p2=str.indexOf(str2);  
x1="";
x1=str.substring(0,p1);
x2=str.substring(p2+1,zlong);
return x1+x2;
}





}
最終更新:2011年04月02日 04:32