All pastes #515888 Raw Edit

kxml-example

public java v1 · immutable
#515888 ·published 2007-05-28 12:40 UTC
rendered paste body
  // Blocking.  public void parse(InputStream in) throws IOException {    Reader reader = new InputStreamReader(in);    XmlParser parser = new XmlParser(reader);    ParseEvent pe = null;    parser.skip();    parser.read(Xml.START_TAG, null, "loc");        boolean trucking = true;    boolean first = true;    String ID[] = new String[100];    Float lat[] = new Float[100];    Float lon[] = new Float[100];    String type[] = new String[100];    String CDATA[] = new String[100];     int index = 0;    while (trucking) {      pe = parser.read();      if (pe.getType() == Xml.START_TAG) {        String name = pe.getName();        if (name.equals("waypont")) {          // bude citat dokym nenajde ukoncovaci tag k </waypont>          while ((pe.getType() != Xml.END_TAG) ||              (pe.getName().equals(name) == false)) {            pe = parser.read();            if (pe.getType() == Xml.START_TAG && // zacina element                pe.getName().equals("name")) { // meno elementu je name              if (pe.getAttributeName(0) == "id") {                ID[index] = pe.getAttributeName(0);              }              pe = parser.read();	      CDATA[index] = pe.getText();            }            else if (pe.getType() == Xml.START_TAG &&                pe.getName().equals("type")) {              // pe.getAtr            }            else if (pe.getType() == Xml.START_TAG &&                pe.getName().equals("link")) {              // pe = parser.read();                                         }	    index++;          }          mRSSListener.itemParsed(title, link, description);        }        else {          // TU KUKAJ ;) <- to je ak by tam bol dajaky element, co nie je wayponot	  Sytem.out.println("nespravny .loc XML");         }      }      // koniec xml      if (pe.getType() == Xml.END_TAG &&            pe.getName().equals("loc"))        trucking = false;    }  }}