See which of your colleagues or former colleagues are already on Java Link: Check out the Contact Finder
Java Web Services » XML » Can any one solve this

513 Views
  21 Replies

+2
Vote Vote
Can any one solve this
Share  
 Type: Professional, Report if fun topic
ATUL
ATUL Picture
67 Posts
back to top
Posted 30-01-2009Reply











12341

pending



Silver Show Saddle, 16inch

825.00

1





Premium Cinch

49.00

1







251222

pending



Winter Blanket(78 inch)

20.00

10









this is xml



and code i am calling from

is

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import java.io.File;

import org.w3c.dom.Document;



import org.w3c.dom.Element;



public class OrderProcessor

{

public static void main(String[] args)

{

File docFile = new File("orders.xml");

Document doc = null ;



try

{

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

//

dbf.setValidating(true);

DocumentBuilder db = dbf.newDocumentBuilder();

doc = db.parse(docFile);



}



catch(javax.xml.parsers.ParserConfigurationException pce)

{

System.out.println("Parser was not configure correctly");

System.exit(1);

}

catch(java.io.IOException ioe)

{

System.out.println("Cannot read input file");

System.exit(1);

}

catch(org.xml.sax.SAXException se)

{

System.out.println("Problem parsing the file");

System.exit(1);

}

catch(java.lang.IllegalArgumentException ae)

{

System.out.println("Please specify an XML source");

System.exit(1);

}

catch(Exception e)

{

System.out.println("Problem parsing the file " + e.getMessage());





}



}

//System.exit(1);

//}

//Element root = doc.getDocumentElement();



//System.out.println("The root element is "+ root.getNodeName());





//}





}







but the output when i run the file is ...

D:\MyProjects>java OrderProcessor

Problem parsing the file









help me out





Intakhab
Intakhab Picture
82 Posts
back to top
  Rated +1 | Posted 30-01-2009

There is no dom parser in class path.. keep the xml.jar xmldom.jar etc..in your classpath....otherewise u jaust keep this jar into jre ext lib folder...
hope so u ll enjoy your progm,,,

ATUL
ATUL Picture
67 Posts
back to top
  Rated 0 | Posted 30-01-2009

xml code is not able to be displayed and neither xml file is supported
so cannot upload xml file

Intakhab
Intakhab Picture
82 Posts
back to top
  Rated 0 | Posted 30-01-2009

xml code is not able to be displayed and neither x... See ATUL's complete reply


1.u just remove header above the xml file....
2.another if u having tag problem then xml file not show....

ATUL
ATUL Picture
67 Posts
back to top
  Rated 0 | Posted 30-01-2009

There is no dom parser in class path.. keep the... See Intakhab's complete reply


where can i get this jar files from

Intakhab
Intakhab Picture
82 Posts
back to top
  Rated +1 | Posted 30-01-2009

There is no dom parser in class path.. keep the... See Intakhab's complete reply


where can i get this jar files from


dom4j-1.6.1.jar,jdom.jar(These jar r avail..on net go search)on goole to write
xml parser jar......................

ATUL
ATUL Picture
67 Posts
back to top
  Rated 0 | Posted 30-01-2009

There is no dom parser in class path.. keep the... See Intakhab's complete reply


where can i get this jar files from


dom4j-1.6.1.jar,jdom.jar(These jar r avail..on net... See Intakhab's complete reply


I downloaded the jar file dom4j-1.6.1
placed the file in jre ... lib
added to classpath but still same error...........

Intakhab
Intakhab Picture
82 Posts
back to top
  Rated 0 | Posted 31-01-2009

There is no dom parser in class path.. keep the... See Intakhab's complete reply


where can i get this jar files from


dom4j-1.6.1.jar,jdom.jar(These jar r avail..on net... See Intakhab's complete reply


I downloaded the jar file dom4j-1.6.1

pla... See ATUL's complete reply


u r using some id..or simple running code thr textpad...

ATUL
ATUL Picture
67 Posts
back to top
  Rated 0 | Posted 31-01-2009

There is no dom parser in class path.. keep the... See Intakhab's complete reply


where can i get this jar files from


dom4j-1.6.1.jar,jdom.jar(These jar r avail..on net... See Intakhab's complete reply


I downloaded the jar file dom4j-1.6.1

pla... See ATUL's complete reply


u r using some id..or simple running code thr text... See Intakhab's complete reply


I have just written code in notepad and also xml and stored as .xml file and now within same directory i have compiled succesfully but running gives the same error ...
and i want to use this in my new project but i dont know XML- and - dom ..

much

Intakhab
Intakhab Picture
82 Posts
back to top
  Rated 0 | Posted 31-01-2009

There is no dom parser in class path.. keep the... See Intakhab's complete reply


where can i get this jar files from


dom4j-1.6.1.jar,jdom.jar(These jar r avail..on net... See Intakhab's complete reply


I downloaded the jar file dom4j-1.6.1

pla... See ATUL's complete reply


u r using some id..or simple running code thr text... See Intakhab's complete reply


I have just written code in notepad and also xml a... See ATUL's complete reply


1. put your all jar into C:\Program Files\Java\jdk1.6.0_01\jre\lib\ext...(means what ever ur jdk version)
2.if y have set path of java.........................then ok...
if not then save path like
C:\Program Files\Java\jdk1.6.0_01\bin; in your envirm varibale....

then after u can work..........

ATUL
ATUL Picture
67 Posts
back to top
  Rated 0 | Posted 31-01-2009

There is no dom parser in class path.. keep the... See Intakhab's complete reply


where can i get this jar files from


dom4j-1.6.1.jar,jdom.jar(These jar r avail..on net... See Intakhab's complete reply


I downloaded the jar file dom4j-1.6.1

pla... See ATUL's complete reply


u r using some id..or simple running code thr text... See Intakhab's complete reply


I have just written code in notepad and also xml a... See ATUL's complete reply


1. put your all jar into C:\Program Files\Java\jd... See Intakhab's complete reply


evry thing is fine same is been used ...
but still....... no effect..

Intakhab
Intakhab Picture
82 Posts
back to top
  Rated 0 | Posted 31-01-2009

There is no dom parser in class path.. keep the... See Intakhab's complete reply


where can i get this jar files from


dom4j-1.6.1.jar,jdom.jar(These jar r avail..on net... See Intakhab's complete reply


I downloaded the jar file dom4j-1.6.1

pla... See ATUL's complete reply


u r using some id..or simple running code thr text... See Intakhab's complete reply


I have just written code in notepad and also xml a... See ATUL's complete reply


1. put your all jar into C:\Program Files\Java\jd... See Intakhab's complete reply


evry thing is fine same is been used ...

b... See ATUL's complete reply


just send the error..means copy the error wat u got.

Pradeep
Pradeep Picture
15 Posts
back to top
  Rated 0 | Posted 31-01-2009

Hello both,
First of all, i would like to appreciate u both for sharing knowledge uninterruptedly. I liked it...
Coming2ur code atul, its working very fine4me. I am using "jre1.5.0_12" JVM. And regarding ur jar files, i don't think u need to import any external jar file for this program. The "rt.jar" under "C:\Program Files\Java\jre1.5.0_12\lib" takes care of all ur vital actions on an xml parsing program. So, please make sure that u recollect this jar and make it available to ur program by setting it into classpath.
Atul, wat i suggest is... Make use of an IDE. For suppose, Eclipse. Set ur latest Jre installed on ur machine in it(Eclipse Preferences.). So that, eclipse handles all those jar file those comes with Jre...

Give a try to the above. Hope, it will Solve ur problem...!
Correct me if m wrong...

Thanks & Regards,
K.R.Pradeep

ATUL
ATUL Picture
67 Posts
back to top
  Rated 0 | Posted 31-01-2009

There is no dom parser in class path.. keep the... See Intakhab's complete reply


where can i get this jar files from


dom4j-1.6.1.jar,jdom.jar(These jar r avail..on net... See Intakhab's complete reply


I downloaded the jar file dom4j-1.6.1

pla... See ATUL's complete reply


u r using some id..or simple running code thr text... See Intakhab's complete reply


I have just written code in notepad and also xml a... See ATUL's complete reply


1. put your all jar into C:\Program Files\Java\jd... See Intakhab's complete reply


evry thing is fine same is been used ...

b... See ATUL's complete reply


just send the error..means copy the error wat u go... See Intakhab's complete reply


D:\MyProjects>java OrderProcessor
Problem parsing the file

on running code this is output plz check this o/p is due to a checked excetion .

ATUL
ATUL Picture
67 Posts
back to top
  Rated +1 | Posted 31-01-2009

Hello both,

First of all, i would like to a... See Pradeep's complete reply


i am using java 1.6.0_11
Aur yaar eclipse iam not familiar with .. completely I can only run simple code and get output but how to add xml file to it and get the o/p in ecllipse 3.4

ATUL
ATUL Picture
67 Posts
back to top
  Rated 0 | Posted 01-02-2009

In ecllipse i am getting cannot read input file
as it is my declared exception
but i have added xml file orders.xml to the source
without using ecllipse i am getting excetion regarding sax.parser which is already declared...

Fedd up yaar....

i think javaranch may hav its solution....

+2
Vote Vote
Share  
 Type: Professional, please report if fun topic

Recent Activity in Forums

05-04-2012.
05-04-2012.
Kanchana posted a new forum topic in
27-02-2012.
11-02-2012.
Kanchana posted a new forum topic in
11-02-2012.