chce wczytac plik xml i wypisac w konsoli w postaci
klucz = wartosc
oto moj kod:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package futbol24;
import javax.microedition.io.*;
import java.io.*;
import org.kxml.io.*;
import org.kxml.parser.*;
/**
*
* @author bart
*/
public class XMLmanager extends Thread{
public Reader rd;
public void run() {
try {
HttpConnection sc = (HttpConnection) Connector.open("http://math.uni.lodz.pl/~kowalcr/Java2/ZAJ2/rekord.xml");
InputStream is = sc.openInputStream();
Reader reader = new InputStreamReader(is);
XmlParser parser = new XmlParser(reader);
ParseEvent pe = null;
pe = parser.read();
for(int i=0; i<pe.getAttributeCount(); i++) {
System.out.println(pe.getAttribute(i).getName() + " = " + pe.getAttribute(i).getValue() + "\n");
}
is.close();
sc.close();
reader.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
ktory wyrzuca wyjatek:
Uncaught exception java/lang/RuntimeException: Method not supported for the given event type!.
i dotyczy on wywolania w petli for()
pe.getAttributeCount();
prosze o pomoc