/** * This will build a JDOM Comment from an existing DOM Comment * * @param comment <code> org.w3c.dom.Comment</code> object * @return <code>Comment</code> - JDOM Comment object * @since JDOM2 */ public org.jdom2.Comment build(org.w3c.dom.Comment comment) { return factory.comment(comment.getTextContent()); }
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList elemList; Element elem; Comment comment; String textContent; Node appendedChild; doc = (Document) load("barfoo", false); elem = doc.createElementNS("http://www.w3.org/1999/xhtml", "body"); comment = doc.createComment("Comment"); appendedChild = elem.appendChild(comment); textContent = comment.getTextContent(); assertEquals("nodegettextcontent12", "Comment", textContent); } /**
protected static XNode parseNode(Node domNode) { if (domNode instanceof Element) { return XElement.parse((Element) domNode); } if (domNode instanceof Text) { return new XText(((Text) domNode).getTextContent()); } if (domNode instanceof Comment) { return new XComment(((Comment) domNode).getTextContent()); } if (domNode instanceof ProcessingInstruction) { return new XProcessingInstruction(((ProcessingInstruction) domNode).getTarget(), ((ProcessingInstruction) domNode).getData()); } if (domNode instanceof DocumentType) { return new XDocumentType(((DocumentType) domNode).getName(), ((DocumentType) domNode).getInternalSubset()); } throw new UnsupportedOperationException("implement " + domNode); }