0
내 xml 파일 :DOM4J를 사용하여 XML을 통해 반복하는 방법
<credentials>
<machine name="xyz">
<cred-pairs>
<cred-pair>
<login>asad</login>
<password>12345</password>
</cred-pair>
<cred-pair>
<login>ggss</login>
<password>97653</password>
</cred-pair>
<cred-pairs>
</machine>
<machine name="pqr">
<cred-pair>
<cred-pair>
<login>ssdas</login>
<password>12345</password>
</cred-pair>
<cred-pairs>
</machine>
</credentials>
클라이언트 :
public Client
{
String login;
String password;
//getters
Client(String login,String password)
{
this.login=login;
this.password=password;
}
}
내 테스트 클래스 :
Class Test{
getMachineByName(String machineName)
{
ArrayList<Client> machineClients=new ArrayList<Client>();
/*here i have to iterate through xml and upon machineName i have to create Client objects using cred-pair(s) in cred-pairs node and add to machineClientsList
}
}
내가 호출하는 경우 getmachineByName(xyz)
, 나는 arraylist에서 모든 cred-pairs를 얻어야합니다. 나는 반복에 혼란 스럽다.