• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

clarification regarding Xerces

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
hope u don't mind answering this simple question from a newbie!!
i have downloaded Xerces parser from the Apache web site and extracted all the required files in my machine in a folder named 'Xerces'.
1)i want to know how to parse my XML files using Xerces???
2)when i write my DOM/SAX programs, how can i parse them using Xerces?
thanks in advance.
(by the way,i have j2sdk1.4.2 installed in my machine)
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SAX: http://xml.apache.org/xerces2-j/sax.html
DOM: http://xml.apache.org/xerces2-j/dom.html
Have a look at the documentation.
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also see the bunch of tutorials from here, it will sure start your engine..
http://www-106.ibm.com/developerworks/views/xml/tutorials.jsp
 
Yell Srik
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dear friends,
i went throught the links u have mentioned, but i am afraid i need more clarifications from u:
i have installed the xerces in a separate folder named "Xerces". now i have written a DOM program for my XML file. now should i save this program as say "XML1DOM.java", then go the command prompt and compile it as
javac XML1DOM.java and run it as java XML1DOM?
is the above procedure correct for parsing an XML file with xerces. if not, how should i proceed.
i hope u don't mind answering such a basic level question.
thanks in advance.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If "XML1DOM" is the name of the class that has a main() method then yes, that's how you execute it (assuming it's in the default package -- if it's not, then you need to specify the fully qualified name like "java com.foobar.XML1DOM"). In addition, you need to make sure that the Xerces .jar file is in the classpath (either via the CLASSPATH environment variable or via the "-classpath path/to/XercesImpl.jar" command-line argument).
 
Balaji Loganathan
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Yell Srik:
[QB] i have installed the xerces in a separate folder named "Xerces". now i have written a DOM program for my XML file. now should i save this program as say "XML1DOM.java", then go the command prompt and compile it as
javac XML1DOM.java and run it as java XML1DOM?
is the above procedure correct for parsing an XML file with xerces. if not, how should i proceed.
[QB]


Yell
  • For brevity, lets create a new directory say(C:\XML)
  • Now copy the files XML1DOM.java and xerces.jar to this directory
  • xercer.jar can be found under the your Xerces folder, or copy the jar files which starts with xerces***.jar, the file size willbe more than 1.7mb
  • Now under the folder C:\xml, type javac -classpath "Xerces.jar" XML1DOM.java
  • The above step is to tell the java compiler to find the xerces related imports from the jar file xerces.jar
  • Now run java -cp "Xerces.jar" XML1DOM
  • Let me know if you are done up to this point.

  • The above step is one way which is specific to xerces parser, the latest jdk got its own xml parser, if you use generic imports for xml then your program can parse xml without
    the need of xerces.
    You can also gobally set the classpath for xerces and other related jars and complie/run the java-xml file without using
    the -classpath or -cp options.
     
    Yell Srik
    Ranch Hand
    Posts: 61
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    hi balaji,
    i am sorry for the delay in replying. actually there has been some problem while installing JDK on my system. as soon as it is resolved, i will work on the procedure u suggested and then get to u.
     
    get schwifty. tiny ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic