【发布时间】:2014-01-28 16:51:09
【问题描述】:
我设法在我的程序中根除此错误的原因:
INVALID_CHARACTER_ERR:指定了无效或非法的 XML 字符。
我做了一个测试应用来确保原因是正确的。
测试代码:
String x = "2TEST"; // <--------- when there is no leading number
// app executes normally
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
try {
builder = factory.newDocumentBuilder();
Document doc = builder.newDocument();
doc.createElement(x);
} catch (ParserConfigurationException e) {
e.printStackTrace();
当我在 2TEST 中删除前导数字时,它工作正常,某些条目中需要前导数字并且无法消除,这种情况有什么解决方法吗?
【问题讨论】: