XML UTF-8输出中的jdom2编码问题

XML UTF-8输出中的jdom2编码问题,xml,encoding,utf-8,fileoutputstream,jdom-2,Xml,Encoding,Utf 8,Fileoutputstream,Jdom 2,我尝试使用jdom2更新现有XML文件中的一些属性值。我在创建xml文件时遇到了utf8编码问题 属性值为“1个学生名词”。 但我在输出中看到的值是: 1	student	Noun 我编写的代码如下所示: SAXBuilder builder = new SAXBuilder(); Document document = document = builder.build(filePath); Element ro

我尝试使用jdom2更新现有XML文件中的一些属性值。我在创建xml文件时遇到了utf8编码问题

属性值为
“1个学生名词”。

但我在输出中看到的值是:

1	student	Noun
我编写的代码如下所示:

SAXBuilder builder = new SAXBuilder();
            Document document = document = builder.build(filePath);

            Element root = document.getRootElement();

            for(Element sentenceElement : root.getChildren("sentence")){

                String transcriptionText = "";

                 for(Element transcriptionElement : sentenceElement.getChildren("transcription")){

                     for(Element wordElement : transcriptionElement.getChildren("word")){
                            transcriptionText += " "+wordElement.getAttributeValue("text");
                     } 

                     transcriptionParser = ParserUtil.getResponse(transcriptionText);
                     transcriptionElement.getAttribute("text").setValue(transcriptionText);
                     transcriptionElement.getAttribute("parser").setValue(transcriptionParser);
                 }

                 for(Element translationElement : sentenceElement.getChildren("translation")){

                        translationParser = getResponse(translationElement.getAttributeValue("text"));
                        translationElement.getAttribute("parser").setValue(translationParser);

                 }
            }

            Format format = Format.getPrettyFormat();

            XMLOutputter xmlOutput = new XMLOutputter(format);


            /*try (OutputStream out = new FileOutputStream(filePath)) {
               xmlOutput.output(document, out);
              }catch(Exception e){
                 e.printStackTrace();
              }
            }*/

            xmlOutput.output(document, Files.newBufferedWriter(Paths.get(filePath),StandardCharsets.UTF_8));
我已经使用了这两个选项:

xmlOutput.output(document, Files.newBufferedWriter(Paths.get(filePath),StandardCharsets.UTF_8));

但这些问题都没有得到解决。如何解决这个问题?

字符串
“1个学生名词”
显然在单词之间包含制表符


因此,如果XML输出包含
1	;学生	;名词
那完全可以。制表符的Unicode值为9和
	
是一个适当的XML实体来表示它。

注意,这与UTF-8或编码无关。如果要在字符串中使用空格而不是制表符,则需要在XML中创建属性节点之前修改字符串。
    try (OutputStream out = new FileOutputStream(filePath)) {
         xmlOutput.output(document, out);
   }catch(Exception e){
         e.printStackTrace();
   }