XML and JAVA


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: XML and JAVA

Hybrid View

  1. #1
    Join Date
    Jul 2005
    Posts
    3

    XML and JAVA



    I have two xml files. One contains all the information about courses of a department and the other contains class time, exam time, labs etc of each courses.

    The first file remains fixed i.e it's never changed (A department rarely changes it's courses). But the other one changes every semester (not all the courses of the first file are offered every semester). The common thing about both files is that both have course id.

    Now I need a way to display information about the offered courses (from the second file) taking some of the information from the first file.

    Take a look at this :

    FILE ONE :


    <course>
    <id>CE 201</id>
    <name>Electrical Engineering</name>
    <credit>4.0</credit>
    </course>

    <course>
    <id>CE 202</id>
    <name>Electronics</name>
    <credit>4.0</credit>
    </course>

    <course>
    <id>CE 301</id>
    <name>Numerical Analysis</name>
    <credit>3.0</credit>
    </course>

    ----------------------------------------------------


    FILE 2 :

    <course>
    <id>CE 202</id>
    <day>Sunday</day>
    ----------------------------------------------------


    A java code will parse the files - match course ids and display :

    Course ID : CE 202 [Matching Key]
    Course Name : Electronics [First File]
    Day : Sunday [Second File]
    ----------------------------------------------------

    I'm using the following two links.

    http://www.developertutorials.com/tu...611/page1.html

    http://www.w3schools.com/xml/tryit.a...catalog_island

    The first link is to create objects (for other stuff) and the second one is to display the schedule in a tabular format.

    Can anyone tell me how I can integrate these two files to create the tabular view of the second link and create objects of only those courses that're offered in the "Second XML FILE".

  2. #2
    Join Date
    Aug 2003
    Posts
    313
    The second link looks like a link to XML stuff for the web. What is the intended viewing method for this information. If it is on the web and you are planning on using xsl, then you probably don't need java at all. If you need the information in a java program, then the best way would probably be for the program to generate a single xml file with the combined information.

    From my experience, the easiest way to do this in Java would be with XPath. It will allow you to query the document using xpath expressions which you can read about here:
    http://java.sun.com/xml/jaxp/dist/1....slt/index.html

    In order to use XPath theres a few things that you have to do. I have a shell .java file on my computer at home that I can post. It's pretty easy.

    Hope this helps.
    ~evlich

Similar Threads

  1. java and xml problems
    By dakkar in forum Java
    Replies: 0
    Last Post: 04-23-2005, 04:25 AM
  2. Replies: 1
    Last Post: 05-02-2002, 07:57 AM
  3. Help student to convert Xml to Java
    By Marco in forum XML
    Replies: 0
    Last Post: 12-11-2000, 10:15 AM
  4. how to use server side xml with java?
    By litstone in forum XML
    Replies: 0
    Last Post: 06-07-2000, 06:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center