我一直在使用xom.nu库来保存和解析应用程序的XML文件。不幸的是,我刚刚意识到它是对我的特殊字符进行XML编码,但是当我调用toString()时它还没有对它们进行解码。
示例:
Element element = new Element("Test");
element.appendChild("This & That"); //Will create XML as follows: <Test>This & That</Test>
//Saved to a file
稍后阅读
//File opened, elements retrieved from file, rootElement is the root element
Element test = rootElement.getFirstChildElement("Test");
System.out.println(test.getValue()); //Prints This & That
如何检索文本以便在返回之前清除输出?如果我不需要,我不想导入另一个库,如果它可以编码,那么它应该能够解码该字符串。