XMLSerializer去掉type属性

项目需要,转出XMLSerializer转出的xml字符串需要去掉app中间的type=“string”;

关键设置如下setTypeHintsEnabled(false)


	String xml = null;
        String resStr = "{'TX':'WS01001', 'T':'0', 'D':'app', 'V':'1.0.0', 'id':'1', 'startCity':'"
                + "杭州" + "', 'arriveCity':'" + "北京" + "'}";
        JSONObject res = JSONObject.fromObject(resStr);
        XMLSerializer xs = new XMLSerializer();
        xs.setTypeHintsEnabled(false);
        xml = xs.write(res);
        System.out.println(xml);


结果入下:


app0WS010011.0.0北京type="string">1杭州


你可能感兴趣的:(杂说)