rendered paste body Class c = this.getClass();
/* Luetaan XML-puusta projektien nimet listaan */
Reader reader = new InputStreamReader(c.getResourceAsStream("project.xml"));
XmlParser parser;
Document xmlDoc = new Document();
try
{
parser = new XmlParser(reader);
xmlDoc.parse(parser);
Element root = xmlDoc.getRootElement();
int childCount = root.getChildCount();
for(int i=1;i<childCount;i=i+2) // Haetaan "project"-tagit
{
Element kid = root.getElement(i);
if(kid.getElement("name").getText().equals(projectname)) // Projektin nimi ok?
{
Element kidsChild = kid.getElement("name");
int personChildCount = kid.getChildCount();
for(int j=1;j<personChildCount;j=j+2) // Haetaan lapset...
{
kidsChild = kid.getElement(j);
if(kidsChild.getName().equals("person")) // Onko Person tagissa
if(kidsChild.getElement("name").getText().equals(personname)) // Oikean niminen gusse?
{
int personWienerCount = kidsChild.getChildCount();
for(int k=1;k<personWienerCount;k=k+2) // Juostaan Person:n lapset läpi
{
if(kidsChild.getElement(k).getName().equals("wiener")) // Juostaan wienerit läpi ja tulostetaan listat valmiiksi
{
String temp = kidsChild.getElement(k).getElement("name").getText()+" ["+
kidsChild.getElement(k).getElement("status").getText()+"] ";
listat.append(temp,null);
}
}
}
186,1-3 47%