Results 1 to 6 of 6
Thread: XML parser
- 03-18-2011, 07:53 PM #1
XML parser
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:Java Code:Element data = new Element("data");
org.w3c.dom.Element is abstract; cannot be instantiated
What does that meen?
- 03-18-2011, 08:34 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
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 DOMLast edited by eRaaaa; 03-18-2011 at 09:43 PM.
- 03-21-2011, 11:03 AM #3
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(...);
try {
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?
- 03-21-2011, 03:47 PM #4
Is this a good tutorual: www.ibm.com/developerworks/java/library/j-dom/
Becose I do that exactly, but also no luck. :(
- 03-21-2011, 03:52 PM #5
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
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 !Last edited by eRaaaa; 03-21-2011 at 06:22 PM.
- 03-21-2011, 04:50 PM #6
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.Last edited by Lund01; 03-24-2011 at 06:04 PM.
Similar Threads
-
Parser API
By sruti_mohan in forum Advanced JavaReplies: 0Last Post: 06-09-2008, 07:23 AM -
JSP Parser????
By chathu03j in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 04-10-2008, 12:08 PM -
DNS name parser 1.2.1
By JavaBean in forum Java SoftwareReplies: 0Last Post: 07-14-2007, 08:21 PM -
XML Parser
By samfuerte in forum XMLReplies: 1Last Post: 07-14-2007, 04:14 PM -
Parser
By Peter in forum Advanced JavaReplies: 2Last Post: 07-04-2007, 07:08 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks