Document createElement - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Document createElement method.

This code example shows how to use the following methods:createElement, getDocumentElement, appendChild
        //          /   \ 
        //         B     C 
        //              / \ 
        //             D   E 
 
        document.appendChild(document.createElement("A"));
        Element a = document.getDocumentElement();
        assertSame(a, DomUtilities.getCommonAncestor(a, a));
 
        Element b = document.createElement("B");
        a.appendChild(b);
        Element c = document.createElement("C");
        a.appendChild(c);
        Element d = document.createElement("D");
        c.appendChild(d);
        Element e = document.createElement("E");
        c.appendChild(e);
 
        assertSame(a, DomUtilities.getCommonAncestor(a, b));
        assertSame(a, DomUtilities.getCommonAncestor(b, a));
        assertSame(a, DomUtilities.getCommonAncestor(b, c));
8
CodeRank
This code example shows how to use the following methods:createElement, createTextNode
 
public class ElementWarningsRenderer { 
    public void renderTo(DslElementDoc elementDoc, String type, Element parent) {
        if (elementDoc.isDeprecated()) {
            Document document = parent.getOwnerDocument();
            Element caution = document.createElement("caution");
            parent.appendChild(caution);
            Element para = document.createElement("para");
            caution.appendChild(para);
            para.appendChild(document.createTextNode(String.format("Note: This %s is ", type)));
            Element link = document.createElement("ulink");
            para.appendChild(link);
            link.setAttribute("url", "../userguide/feature_lifecycle.html");
            link.appendChild(document.createTextNode("deprecated"));
            para.appendChild(document.createTextNode(" and will be removed in the next major version of Gradle."));
        } 
        if (elementDoc.isIncubating()) {
            Document document = parent.getOwnerDocument();
            Element caution = document.createElement("caution");
            parent.appendChild(caution);
8
CodeRank
This code example shows how to use the following methods:createElement
This code example shows how to use the following methods:createElement, appendChild
 
        // Retrieve the DOM document to populate 
        Document doc = result.getDocument();
 
        // Append the root node 
        Node mailElt = doc.createElement("mail");
        doc.appendChild(mailElt);
 
        // Append the child nodes and set their text content 
        Node statusElt = doc.createElement("status");
        statusElt.setTextContent("received");
        mailElt.appendChild(statusElt);
 
        Node subjectElt = doc.createElement("subject");
        subjectElt.setTextContent("Message to self");
        mailElt.appendChild(subjectElt);
 
        Node contentElt = doc.createElement("content");
        contentElt.setTextContent("Doh!");
        mailElt.appendChild(contentElt);

7
CodeRank
This code example shows how to use the following methods:createElement, getDocumentElement
        DOMImplementationRegistry registry;
        registry = DOMImplementationRegistry.newInstance();
        DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
        Document doc = impl.createDocument(null, format, null);
        Element root, text, entry;
        root = doc.getDocumentElement();
        root.appendChild(text = doc.createElement("Text"));
        text.appendChild(entry = doc.createElement("TextEntry"));
        // keyword isn't #REQUIRED by the standard metadata format. 
        // However, it is required by the PNG format, so we include it here. 
        entry.setAttribute("keyword", "Comment");
        entry.setAttribute("value", "Some demo comment");
        meta.mergeTree(format, root);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:createElement, appendChild
	 * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer) 
	 */ 
	public String getMemento(ISourceContainer container) throws CoreException {
		SourceFoldersRelativePathSourceContainer sourceContainer = (SourceFoldersRelativePathSourceContainer) container;
		Document document = newDocument();
		Element element = document.createElement("project"); //$NON-NLS-1$
		IProject project = sourceContainer.getProject();
		if (project != null) {
			element.setAttribute("name", project.getName()); //$NON-NLS-1$
		} 
		element.setAttribute("referencedProjects", String.valueOf(sourceContainer.isSearchReferencedProjects())); //$NON-NLS-1$
		document.appendChild(element);
		return serializeDocument(document);
	} 
 
	/* (non-Javadoc) 
	 * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#createSourceContainer(java.lang.String) 
	 */ 
	public ISourceContainer createSourceContainer(String memento) throws CoreException {
		Node node = parseDocument(memento);
7
CodeRank
This code example shows how to use the following methods:createElement, appendChild
	 * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer) 
	 */ 
	public String getMemento(ISourceContainer container) throws CoreException {
		DirectorySourceContainer folder = (DirectorySourceContainer) container;
		Document document = newDocument();
		Element element = document.createElement("directory"); //$NON-NLS-1$
		element.setAttribute("path", folder.getDirectory().getAbsolutePath()); //$NON-NLS-1$
		String nest = "false"; //$NON-NLS-1$
		if (folder.isComposite()) {
			nest = "true"; //$NON-NLS-1$
		} 
		element.setAttribute("nest", nest); //$NON-NLS-1$
		document.appendChild(element);
		return serializeDocument(document);
	} 
} 
7
CodeRank
This code example shows how to use the following methods:createElement, createTextNode
7
CodeRank
This code example shows how to use the following methods:createElement
		} 
	} 
 
	private static void ProcessUserProfileConfigData(UserProfileData a_UPData,
			Context aUI, Document doc, Element rootElement) {
		Element elroot = doc.createElement("UserProfile");
		Element el = doc.createElement("Name");
		el.setAttribute("value", a_UPData.getUserName());
		elroot.appendChild(el);
 
		el = doc.createElement("Password");
		el.setAttribute("value", a_UPData.getPassword());
		elroot.appendChild(el);
 
		el = doc.createElement("LocalIP");
		el.setAttribute("value", a_UPData.getLocalIP());
		elroot.appendChild(el);
		 
		el = doc.createElement("LocalPort");
		el.setAttribute("value", Short.toString(a_UPData.getLocalPort()));

7
CodeRank
This code example shows how to use the following methods:createElement, createElementNS, appendChild
        result.setNamespaceAware(true);
 
        // Populate the DOM document 
        Document doc = result.getDocument();
 
        Node mailElt = doc.createElementNS(
                "http://www.rmep.org/namespaces/1.0", "mail"); 
        doc.appendChild(mailElt);
 
        Node statusElt = doc.createElement("status");
        statusElt.setTextContent("received");
        mailElt.appendChild(statusElt);
 
        Node subjectElt = doc.createElement("subject");
        subjectElt.setTextContent("Message to self");
        mailElt.appendChild(subjectElt);
 
        Node contentElt = doc.createElement("content");
        contentElt.setTextContent("Doh!");
        mailElt.appendChild(contentElt);

7
CodeRank

Related Document createElement Questions & Answers:

createElement Method Overview
Creates an element of the type specified.
See Code Examples for other Java 8 Document Methods: