0
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://www.taxmanntechnologies.com/">[{"INT_ID":"102010000000000015","INT_Section_ID":"102120000000000069", "Section_No":"Section - 16 ","Heading":" Functions of Central Board"}]</string>

我有我要删除的数据<string xmlns="http://www.taxmanntechnologies.com/"> </String >
以便我可以获取 JSON 数据,任何人都可以告诉我如何删除它以便我可以解析它。

4

1 回答 1

1

如果你想“正确”地做,你需要解析 xml,流行的 xml 解析技术/库是 SAX 和 DOM,SAX 更受事件驱动,使用起来有点棘手,而且 DOM 速度较慢,尤其是对于大型 xml 文档。

对于这个用例,我将使用 DOM 解析器,大致如下:

File fXmlFile = new File("c:\\file.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();

NodeList nList = doc.getElementsByTagName("string");
String json =  nList.item(0).getNodeValue();
于 2013-01-10T09:43:51.997 回答