<app:service xmlns:app="http://www.w3.org/2007/app"...>
<app:workspace>
<atom:title type="text">Data</atom:title>
<app:collection . . .>
<atom:title type="text">CourseContentSet</atom:title>
<demo:member-title>CourseContent</demo:member-title>
</app:collection>
<app:collection . . .>
<atom:title type="text">UnitContentSet</atom:title>
<demo:member-title>UnitContent</demo:member-title>
</app:collection>
</app:workspace>
</app:service>
我如何获得demo:member-title?
我尝试这样做,但没有成功...
soapDatainJsonObject = XML.toJSONObject(soapmessageString);
JSONObjectsongs=soapDatainJsonObject.getJSONObject("app:service");
JSONObject songs2 = songs.getJSONObject("app:workspace");
String content = songs2.getString("app:collection")
System.out.println(content);
我如何访问XML文件的内部?通过JSON。 我想获取CourseContent,UnitContent..etc
答案 0 :(得分:0)
您需要解析每个深度。试试这个:
JSONObject soapDatainJsonObject = XML.toJSONObject(soapmessageString);
JSONObject songs= soapDatainJsonObject.getJSONObject("app:service");
JSONObject songs2 = songs.getJSONObject("app:workspace");
JSONArray atomArray = songs2.getJSONArray("app:collection");
JSONObject atomTitle = atomArray.getJSONObject(0).getJSONObject("atom:title");
String content = atomTitle.getString("content");
System.out.println(content);