要点は
<?xml version="1.0" encoding="utf-8">
<?xml version="1.0" encoding="utf-8"?>
それはそれをより良く機能させます;)
そして、あなたがやりたいことをするために:
123qwdaasdt6708 ... 8yを出力し、name="login"を取得します
次のようにこれを行う必要があります:
public static void debugXML(){
try {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File("D:\\Loic_Workspace\\Test2\\res\\test.xml"));
NodeList ndList = doc.getElementsByTagName("response");
System.out.println(ndList.item(0).getTextContent());
System.out.println(ndList.item(0).getAttributes().item(0));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
System.out.println(ndList.item(0).getTextContent()) ==>は123qwdaasdt6708uu12edhajsup71y2ehno;aishdp18yu2hbd8yを提供します
System.out.println(ndList.item(0).getAttributes()。item(0)); ==> name = "login"を指定します。ログインしたばかりの場合は、System.out.println(ndList.item(0).getAttributes()。item(0).getTextContent());を実行します。
それが役に立てば幸い ;)