格式XML FileContent时内容已更改

时间:2018-05-29 08:44:38

标签: java xml java-7

我使用以下代码来合成xml内容。

Alamofire.request(url, method: method ?? HTTPMethod.get, parameters: parameters,
        encoding: encoding ?? URLEncoding.default, headers: headers)
        .responseString{
        (afResponse : DataResponse<String>) -> Void in
    ....
}

我的xml内容标记的值类似于此Private Sub CheckBox1_Click(): Check_Just CheckBox1: End Sub Private Sub CheckBox2_Click(): Check_Just CheckBox2: End Sub Private Sub CheckBox3_Click(): Check_Just CheckBox3: End Sub Sub Check_Just(CheckBox) 'Disable false triggers when unchecking boxes If CheckBox.Value = False Or CheckBox.GroupName = "" Then Exit Sub 'Uncheck all other control with same groupname Dim ctl As control For Each ctl In CheckBox.Parent.Controls If TypeName(ctl) = "CheckBox" Then If ctl.GroupName = CheckBox.GroupName And Not ctl Is CheckBox Then ctl.Value = Unchecked Next End Sub ,但它返回的值类似于public String xMLFileContentFormat(String fileContent) { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); InputSource inputSource = new InputSource(new StringReader(fileContent)); Document document = documentBuilder.parse(inputSource); OutputFormat format = new OutputFormat(document); format.setLineWidth(65); format.setIndenting(true); format.setIndent(1); Writer out = new StringWriter(); XMLSerializer serializer = new XMLSerializer(out, format); serializer.serialize(document); return out.toString(); } catch (IOException e) { LOGGER.error("Exception", e); return EMPTY_SPACE; } catch (Exception e) { LOGGER.error("Exception", e); } return fileContent; } 。即最后两个xml特殊字符被转换为原始符号。但我需要与之前相同的XML内容。

我怎样才能得到它。

0 个答案:

没有答案