<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 格式不正确,并且元素包含"&"和"?"Org.json 没有转换这个。任何帮助将不胜感激。我真的被困在这里.我试过了
org.json.JSONObject xmlJSONObj = XML.toJSONObject(TEST_XML_STRING);
String jsonPrettyPrintString = xmlJSONObj.toString(PRETTY_PRINT_INDENT_FACTOR);
System.out.println(jsonPrettyPrintString);
但是没有运气。再次感谢
您必须将出现的'&'
替换为&
实体,否则它不是有效的 XML。