我想使用JAVA连接来自xml文件的多个标记值。.xml如下所示:
<test>
<testcase>
<teststep> row 1 </teststep>
<teststep> row 2 </teststep>
<teststep> row 3 </teststep>
<title> Frist Test </title>
</testcase>
</test>
<test>
<testcase>
<teststep> row 20 </teststep>
<teststep> row 10 </teststep>
<teststep> row 30 </teststep>
<title> Second Test </title>
</testcase>
</test>结果应该是这样的:
row 1 row 2 row 3
row 10 row 20 row 30应该有两个变量。
我试过了:
NodeList nodeList5 = doc.getElementsByTagName("teststep");
for (int x = 0, size = nodeList5.getLength(); x < size; x++) {
description = description + nodeList5.item(x).getTextContent();
}
System.out.println("Test Description: " + description);但是我得到的是:行1行2行3行10行20行30,只有一个变量。
https://stackoverflow.com/questions/50553142
复制相似问题