我使用JAVA构建XML,我的元素具有很少的属性,该属性包含' - '
but when setting attibute as :
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.newDocument();
Element dffgr=doc.createElement("diffgr:diffgram");
dffgr.setAttribute("xmlns:msdata", "urn:schemas-microsoft-com:xml-msdata".toString());
dffgr.setAttribute("xmlns:diffgr", "urn:schemas-microsoft-com:xmldiffgram-v1".toString());
'-' is replaced by 'xAD'
as Output is :
<diffgr:diffgram xmlns:diffgr="urn:schemasέicrosoftΣom:xmlΤiffgramζ1" xmlns:msdata="urn:schemasέicrosoftΣom:xmlέsdata">
and desired output is :
<diffgr:diffgram xmlns:msdata="urn:schemasmicrosoftcom:xmlmsdata" xmlns:diffgr="urn:schemasmicrosoftcom:xmldiffgramv1">
请帮助。
答案 0 :(得分:0)
复制并粘贴此内容:
dffgr.setAttribute("xmlns:msdata", "urn:schemas-microsoft-com:xml-msdata");
dffgr.setAttribute("xmlns:diffgr", "urn:schemas-microsoft-com:xmldiffgram-v1");
-
使用了错误的字符。