我只想要app_id
“Rahul2测试”。
我没有将这个xml存储在文件中,我怎么能得到它?
代码:
String s=resultWrapper.getAppBuilds();
System.out.println(s);
输出:
<application app_name="Rahul1 Test" app_id="18" >
<customfield name="Custom 1" value=""/>
<customfield name="Custom 2" value=""/>
<customfield name="Custom 3" value=""/>
<customfield name="Custom 4" value=""/>
<customfield name="Custom 5" value=""/>
<customfield name="Custom 6" value=""/>
<customfield name="Custom 7" value=""/>
<customfield name="Custom 8" value=""/>
<customfield name="Custom 9" value=""/>
<customfield name="Custom 10" value=""/>
<build version>
</build>
</application>
<application app_name="Rahul2 Test" app_id="196" >
<customfield name="Custom 1" value=""/>
<customfield name="Custom 2" value=""/>
答案 0 :(得分:0)
将String转换为DOM xml(https://stackoverflow.com/a/3906936/58082),然后使用XPATH获取属性(How to get attribute value using XPath in Java?)