【发布时间】:2015-12-22 04:45:02
【问题描述】:
我正在开发 android 项目,在某些任务中我需要创建 xml 文档文件。 我需要像这样创建包含冒号的属性
<APPLICAD_EXPORT xsi:noNamespaceSchemaLocation="file:///c:/temp/applicad-export.xsd">
我可以成功创建xml文件,但问题是我无法为属性APPLICAD_EXPORT添加冒号。
到目前为止,我确实喜欢这样为属性前缀获取冒号
XmlSerializer serializer = Xml.newSerializer();
//we set the FileOutputStream as output for the serializer, using UTF-8 encoding
serializer.setOutput(fileos, "UTF-8");
//Write <?xml declaration with encoding (if encoding not null) and standalone flag (if standalone not null)
serializer.startDocument(null, Boolean.valueOf(true));
//set indentation option
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
serializer.startTag(null, "APPLICAD_EXPORT");
serializer.attribute(null, "xsi:noNamespaceSchemaLocation", "file:///c:/temp/applicad-export.xsd");
但它显示错误提示 Specification task value for attribute xsi
我想可能有一些方法可以实现这一点,但我想不通。
【问题讨论】:
标签: java android xml attributes xmlserializer