I have programed an file to create an XML file.
But that was programmed myself.
Now I would like to create one with an DOM parser.
So I start with an:
But then I get an error:
Element data = new Element("data");
org.w3c.dom.Element is abstract; cannot be instantiated
What does that meen?
Element is an interface so you can`t create an object of that class!
Element (Java 2 Platform SE v1.4.2)
You have to create a DocumentBuilder, respectively a document with builder.newDocument() and then you can create an Element with (Element) document.createElement("data");
See: Creating and Manipulating a DOM
How exactly do you meen that?
Becose it is a school project and for this I need to read in a txt file, and make there an XML file from. At the moment I have:
Public class ......
Public static void main ......
And then I have the Element ....... = new Element(...);
After the try we read we file we would like to transform to an XML file.
That is how the program would look like.
But do you meen I should take away the public static void main line?
Is this a good tutorual: www.ibm.com/developerworks/java/library/j-dom/
Becose I do that exactly, but also no luck. :(
Ok tell us first which library do you want to use? JDOM ? Then you have used the wrong import !
Don`t use import org.w3c.dom.Element; ,
use import org.jdom.Element; instead of that, then you are able to instantiate an Element object !
I was thinking there only was DOM and SAX. O_o
Will have a look at this one then.
Hopefully then it will work.
Thanks for the help. :)
I think I am also gonna look to the w3c.dom tutorial.
Becose that sounds better.
Then I also don't need to install everything all the time if I wouk on another computer.