You don't mention the version of java you use. From 1.4 and up you can access xml via jaxp. Consider using that, and your code will not depend on any parser implementation. (The same interfaces you use, - DocumentBuilderFactory and DocumentBuilder) DocumentBuilder.newDocument() returns an empty instance of a document, whatever implementation used.
FPI wrote:
I'm not complety new to DOM, I've been using for javascript programing.
I also have a basic idea of XML.
Now i'm developing a Java application, so I would like to use XML. So I've choosen Xerces. I would like to create a completely new DOM Document, but I don't know how, or at least it doesn't work. This are my first steps in Xerces.
Thanks in advance.
This is my code:
public class App {
private App(){} //Disable Instanciation.
public static void main(String[] args) throws Exception{
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
System.out.println(dbf);
DocumentBuilder db=dbf.newDocumentBuilder();
System.out.println(db);
//org.w3c.dom.DocumentType
DocumentType doctyp=db.getDOMImplementation().createDocumentType("NETMESSAGE","","");
System.out.println(doctyp);
//org.w3c.dom.Document
Document doc=db.getDOMImplementation().createDocument("ns", "", doctyp);
System.out.println(doc);
Element docelem=doc.createElement("html");
System.out.println(docelem);
doc.getDocumentElement().appendChild(docelem);
System.out.println(doc);
}
}
This is the execution results:
$ java App
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[PROTREDES: null]
[#document: null]
[html: null]
[#document: null]
$
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
