本文整理了Java中org.dom4j.dom.DOMDocument
类的一些代码示例,展示了DOMDocument
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DOMDocument
类的具体详情如下:
包路径:org.dom4j.dom.DOMDocument
类名称:DOMDocument
[英]DOMDocument
implements an XML document which supports the W3C DOM API.
[中]DOMDocument
实现了一个支持W3CDOMAPI的XML文档。
代码示例来源:origin: org.dom4j/dom4j
public org.w3c.dom.Document createDocument(String namespaceURI,
String qualifiedName, org.w3c.dom.DocumentType docType)
throws org.w3c.dom.DOMException {
DOMDocument document;
if (docType != null) {
DOMDocumentType documentType = asDocumentType(docType);
document = new DOMDocument(documentType);
} else {
document = new DOMDocument();
}
document.addElement(createQName(qualifiedName, namespaceURI));
return document;
}
代码示例来源:origin: org.dom4j/dom4j
/**
* Marshals the given {@link javax.xml.bind.Element}in to its DOM4J
* counterpart.
*
* @param element
* JAXB Element to be marshalled
*
* @return the marshalled DOM4J {@link org.dom4j.Element}
*
* @throws JAXBException
* when an error occurs
*/
protected org.dom4j.Element marshal(javax.xml.bind.Element element)
throws JAXBException {
DOMDocument doc = new DOMDocument();
getMarshaller().marshal(element, doc);
return doc.getRootElement();
}
代码示例来源:origin: org.dom4j/dom4j
public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild) throws DOMException {
checkNewChildNode(newChild);
return DOMNodeHelper.insertBefore(this, newChild, refChild);
}
代码示例来源:origin: org.dom4j/dom4j
public Document createDocument() {
DOMDocument answer = new DOMDocument();
answer.setDocumentFactory(this);
return answer;
}
代码示例来源:origin: org.dom4j/dom4j
public org.w3c.dom.Node getLastChild() {
return DOMNodeHelper.asDOMNode(node(nodeCount() - 1));
}
代码示例来源:origin: gocd/gocd
public Document toXml(XmlWriterContext writerContext) {
DOMElement root = new DOMElement("scheduledJobs");
for (WaitingJobPlan jobPlan : jobPlans) {
DOMElement jobElement = getXmlForJobPlan(writerContext, jobPlan);
root.add(jobElement);
}
DOMDocument domDocument = new DOMDocument(root);
return domDocument;
}
代码示例来源:origin: org.dom4j/dom4j
public org.w3c.dom.DOMImplementation getImplementation() {
if (getDocumentFactory() instanceof org.w3c.dom.DOMImplementation) {
return (org.w3c.dom.DOMImplementation) getDocumentFactory();
} else {
return DOCUMENT_FACTORY;
}
}
代码示例来源:origin: org.dom4j/dom4j
public DOMDocument(String name, DOMElement rootElement,
DOMDocumentType docType) {
super(name, rootElement, docType);
init();
}
代码示例来源:origin: org.dom4j/dom4j
public org.w3c.dom.Element getDocumentElement() {
return DOMNodeHelper.asDOMElement(getRootElement());
}
代码示例来源:origin: org.dom4j/dom4j
public NodeList getChildNodes() {
return DOMNodeHelper.createNodeList(content());
}
代码示例来源:origin: org.dom4j/dom4j
public org.w3c.dom.Element getElementById(String elementId) {
return DOMNodeHelper.asDOMElement(elementByID(elementId));
}
代码示例来源:origin: org.dom4j/dom4j
public org.w3c.dom.DocumentType getDoctype() {
return DOMNodeHelper.asDOMDocumentType(getDocType());
}
代码示例来源:origin: org.dom4j/dom4j
public org.w3c.dom.Node getFirstChild() {
return DOMNodeHelper.asDOMNode(node(0));
}
代码示例来源: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: dom4j/dom4j
public void testBug1148333() {
DOMDocumentFactory factory = (DOMDocumentFactory) DOMDocumentFactory
.getInstance();
DOMDocument doc = (DOMDocument) factory.createDocument();
Element el = doc.addElement("root");
el.addNamespace("pref2", "uri2");
DOMDocument clone = (DOMDocument) doc.cloneNode(true);
assertNotSame(doc, clone);
assertNodesEqual(doc, clone);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j
public Document createDocument() {
DOMDocument answer = new DOMDocument();
answer.setDocumentFactory(this);
return answer;
}
代码示例来源:origin: dom4j/dom4j
public org.w3c.dom.Node getLastChild() {
return DOMNodeHelper.asDOMNode(node(nodeCount() - 1));
}
代码示例来源:origin: stackoverflow.com
// In php
$dd = new DOMDocument();
// file_get_contents will simply convert the entire web address into a String
$dd->loadXML( file_get_contents( "http://" . $_GET[ 'loadedURL' ] ) );
$scripts = $dd->getElementsByTagName( "script" );
// iterate through the website and remove all script tags.
for( $i = 0; $i < $scripts->length; $i++ )
{
$current = $scripts->item( $i );
$current->parentNode->removeChild( $current );
}
// output it to the dummy page.
echo $dd->saveXML();
代码示例来源:origin: org.dom4j/dom4j
public org.w3c.dom.Attr createAttributeNS(String namespaceURI,
String qualifiedName) throws DOMException {
QName qname = getDocumentFactory().createQName(qualifiedName,
namespaceURI);
return (org.w3c.dom.Attr) getDocumentFactory().createAttribute(null,
qname, null);
}
代码示例来源:origin: org.dom4j/dom4j
public DOMDocument(DOMElement rootElement) {
super(rootElement);
init();
}
内容来源于网络,如有侵权,请联系作者删除!