如何从Java中的XML内容中的元素内容中获取文本内容(JSON)

时间:2014-05-30 11:10:26

标签: xml json

我有String这是一个XML元素。我已将此元素作为有效内容元素传递给JSON。我能够发送请求。如何从XML元素(String)中取出除CDATA之外的JSON内容?

我将请求XML元素发送为:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<saveProject>
<data>
<![CDATA[{"createProject":{"project": {"createDate": "2014-03-20","createdBy": "PARAMETER","endDate": "2014-05-23","owner": {"address":{"city":"Bangalore","country":"India","state":"Karnataka","street":"Address Line 1,Address Line 2","zip":"560001"}"contactNo":"9823984234","emailID":"ravi@mphasis.com","name":"Mphsais"}"phase":"Design","projDesc":"Test Desc","projName":"Ravi-Test","startDate":"2014-03-18"}}}]]>]]&gt;
<![CDATA[</data></saveProject>]]>

我希望输出为:

{"createProject":{"project": {"createDate": "2014-03-20","createdBy": "PARAMETER","endDate": "2014-05-23","owner": {"address":{"city":"Bangalore","country":"India","state":"Karnataka","street":"Address Line 1,Address Line 2","zip":"560001"}"contactNo":"9823984234","emailID":"ravi@mphasis.com","name":"Mphsais"}"phase":"Design","projDesc":"Test Desc","projName":"Ravi-Test","startDate":"2014-03-18"}}}

任何人都可以帮助一些代码来实现这一目标。

0 个答案:

没有答案