本文整理了Java中org.dom4j.dom.DOMDocument.asXML()
方法的一些代码示例,展示了DOMDocument.asXML()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DOMDocument.asXML()
方法的具体详情如下:
包路径:org.dom4j.dom.DOMDocument
类名称:DOMDocument
方法名:asXML
暂无
代码示例来源:origin: dom4j/dom4j
public void testNamespace() throws Exception {
String xml = "<prefix:root xmlns:prefix=\"myuri\" />";
SAXReader xmlReader = new SAXReader(DOMDocumentFactory.getInstance());
DOMDocument d = (DOMDocument) xmlReader.read(new StringReader(xml));
assertEquals("namespace prefix not correct", "prefix", d
.getRootElement().getNamespace().getPrefix());
assertEquals("namespace uri not correct", "myuri", d.getRootElement()
.getNamespace().getURI());
System.out.println(d.asXML());
}
代码示例来源:origin: com.atlassian.jira/jira-core
public String toXML(final IndexDocumentConfiguration indexDocumentConfiguration)
{
final DOMDocument document = new DOMDocument();
final Element configurationElement = new DOMElement(INDEX_DOCUMENT_CONFIGURATION_ROOT);
configurationElement.add(new DOMAttribute(QName.get(INDEX_DOCUMENT_ENTITY_KEY_ATTRIBUTE), indexDocumentConfiguration.getEntityKey()));
document.setRootElement(configurationElement);
for (final KeyConfiguration keyConfiguration : indexDocumentConfiguration.getKeyConfigurations())
{
final Element keyConfigurationElement = new DOMElement(INDEX_DOCUMENT_KEY_ELEMENT);
keyConfigurationElement.add(new DOMAttribute(QName.get(INDEX_DOCUMENT_KEY_PROPERTY_KEY_ATTRIBUTE), keyConfiguration.getPropertyKey()));
for (final ExtractConfiguration extractConfiguration : keyConfiguration.getExtractorConfigurations())
{
final Element extractConfigurationElement = new DOMElement(INDEX_DOCUMENT_EXTRACT_ELEMENT);
extractConfigurationElement.add(new DOMAttribute(QName.get(INDEX_DOCUMENT_EXTRACT_PATH_ATTRIBUTE), extractConfiguration.getPath()));
extractConfigurationElement.add(new DOMAttribute(QName.get(INDEX_DOCUMENT_EXTRACT_TYPE_ATTRIBUTE), extractConfiguration.getType().name()));
extractConfiguration.getAlias().foreach(new Effect<String>()
{
@Override
public void apply(final String alias)
{
extractConfigurationElement.add(new DOMAttribute(QName.get(INDEX_DOCUMENT_EXTRACT_ALIAS_ATTRIBUTE), alias));
}
});
extractConfiguration.getPluginName().ifPresent((pluginName) -> extractConfigurationElement.addAttribute(QName.get(INDEX_DOCUMENT_EXTRACT_CONFLICTING_PLUGIN_NAME), pluginName));
keyConfigurationElement.add(extractConfigurationElement);
}
configurationElement.add(keyConfigurationElement);
}
return document.asXML();
}
内容来源于网络,如有侵权,请联系作者删除!