public static void printFiles(NodeList node) {
for (int i = 0; i < node.getLength(); i++) {
Node file = node.item(i);
String nodeValue = file.getAttributes().getNamedItem("urlName").getNodeValue();
System.out.println(nodeValue);
}
}
output:
0a4f171c-e0a4-4aa8-b43b-3989c235ff58.txt
0ccfa1a4-16b0-4e1f-abc9-e17907bb591f.txt
17c0545b-377e-4e0a-bb45-29f38fc91533.txt
3b341bf0-2cd7-46fe-a834-5b67804e5ff1.txt
48121209-d58e-4565-83b7-05062799be6e.txt
511b7a89-e4de-4f6e-9c8f-5ba65f675d7b.txt
compress.txt
dadadada.txt
e0c44cb9-2b1c-444c-a429-64531ea6a9a0.txt
e68b1d1d-9a66-4678-a6c1-76c64ae8be08.txt
hgafgahfka.txt
jdjajhdajdajd.txt
test1.txt
test2.txt
我解析了xml文档,并通过for循环获取了值,但是这些值必须在List之类的单个位置,以便我可以传递给其他一些函数。请告诉我如何在列表中添加这些函数.Below是代码和当前输出。
答案 0 :(得分:0)
String input = "hello world";
List<String> list = new ArrayList<>();
list.add(input);
System.out.println(list.get(0));
> hello world
祝你好运