<list>
<interfaceReachability type="Critical" count="345" httpLink="searchLradIfAction_pageId?isAscending=true&operation=monitor&searchApByType=AllTypes&searchRadioTypeallRadios=true&searchApType=homePage&severity=1" />
<interfaceReachability type="No Alarms" count="6216" httpLink="searchLradIfAction_pageId?isAscending=true&operation=monitor&searchApByType=AllTypes&searchRadioTypeallRadios=true&searchApType=homePage&severity=5" />
<interfaceReachability type="Minor" count="145" httpLink="searchLradIfAction_pageId?isAscending=true&operation=monitor&searchApByType=AllTypes&searchRadioTypeallRadios=true&searchApType=homePage&severity=3" />
</list>
我想将此 XML转换为Json 。由于此XML格式不正确且元素包含'&amp;'和'?' Org.json没有转换它。任何帮助将非常感激 。我真的卡在这里。我试过了
org.json.JSONObject xmlJSONObj = XML.toJSONObject(TEST_XML_STRING);
String jsonPrettyPrintString = xmlJSONObj.toString(PRETTY_PRINT_INDENT_FACTOR);
System.out.println(jsonPrettyPrintString);
但没有运气。再次感谢
答案 0 :(得分:0)
您必须用'&'
实体替换&
的出现次数,否则它不是有效的XML。