Reputation: 27
I am new to Java and wanted to know if I have an xml file such as this:
`<?xml version="1.0" encoding="UTF-8"?>
<Runners>
<Runner Name="Germany">
<RunnersMoveIncrement>70</RunnersMoveIncrement>
<RestPercentage>10</RestPercentage>
</Runner>
<Runner Name="US">
<RunnersMoveIncrement>10</RunnersMoveIncrement>
<RestPercentage>9</RestPercentage>
</Runner>
<Runner Name="UK">
<RunnersMoveIncrement>20</RunnersMoveIncrement>
<RestPercentage>7</Restpercentage>
</Runner>
<Runner Name="CHINA">
<RunnersMoveIncrement>30</RunnersMoveIncrement>
<RestPercentage>15</RestPercentage>
</Runner>
</Runners>'
how do I read this and create threads for this xml file for each of the runner information using the attributes given ? There are so many articles saying so many ways. I am really confused what to do. Can someone give me some idea what to do or a reference as to how to do this?
Upvotes: 0
Views: 119
Reputation: 909
There is several solution to read XML file with Java but I think you have to make the search by yourself. Here comes some trails :
According to me, a good programmer is curious ; don't just ask a question and wait for an answer ;)
A simple way to use threads is :
public class MyThread extends Thread {
public void run() {
// What you want to do here ...
}
}
or ...
public class MyRunnable implements Runnable {
public void run() {
// What you want to do here ...
}
}
Upvotes: 2