Solved

Filling tables with XML data

Posted on 2004-04-24
21
305 Views
Last Modified: 2013-11-23
Hi!!
I need help with this!! I don't know the right way to implement such a problem!
Here is the scenario:
I do have a number of tables (relations) created in MS Access and I do have an XML document now what I'm looking for is to fill these tables with data from the XML document!

Here are the tables that I have (IDs are auto numbered fields)
Table Name: datee
   Fields:
      1- datee_ID
      2- datee_day
      3- datee_month
      4- datee_year
Table Name: paragraph
   Fields:
      1- paragraph_ID
      2- paragraph_String
Table Name: month
   Fields:
      1- month_ID
      2- month_String
Table Name: notee
   Fields:
      1- notee_ID
      2- notee_to
      3- notee_from
      4- notee_heading
      5- notee_datee_day
      6- notee_datee_month
      7- notee_datee_year
Table Name: year
   Fields:
      1- year_ID
      2- year_String
Table Name: day
   Fields:
      1- day_ID
      2- day_String
Table Name: to
   Fields:
      1- to_ID
      2- to_String
Table Name: from
   Fields:
      1- from_ID
      2- from_String
Table Name: heading
   Fields:
      1- heading_ID
      2- heading_String
Table Name: notee_paragraph
   Fields:
      1- notee_paragraph_ID
      2- notee_ParentID
      3- notee_paragraph_String

Here is the XML document
<notee>
    <to>Jane</to>
    <from>Tom</from>
    <heading>Reminder</heading>
    <paragraph>Hi</paragraph>
    <paragraph>Don’t be late!</paragraph>
    <datee>
        <day>13</day>
        <month>May</month>
        <year>2004</year>
    </datee>

   <to>Mark</to>
    <from>Ed</from>
    <heading>Invitation</heading>
    <paragraph>Hello</paragraph>
    <paragraph>Please come</paragraph>
    <paragraph>Take care</paragraph>
    <datee>
        <day>14</day>
        <month>March</month>
        <year>2004</year>
    </datee>

</notee>

Any help or advice will be highly appreciated!
0
Comment
Question by:lina000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
  • 4
  • +1
21 Comments
 
LVL 7

Expert Comment

by:maheshexp
ID: 10910845
get a XML parser and make a database connectivity...
read teh data from XML and make a INSERT statements from the values....and update the information in the database
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10910851
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10910942
You should be able to use a SAX based parser with good results.  As of version 1.4 of the JDK there is a SAX parser included with the JDK. You can find the SAX parser and related classes here: http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/package-frame.html

A SAX parser is event based and will send events to registered listerners. Another option is to use the DOM model, in which the whole XML document is read into memory, parsed, and then made searchable. There is a DOM, or document arser available in the above package as well.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10911008
0
 

Author Comment

by:lina000
ID: 10911174
Thanks all for replying!
I used DOM class to parse the XML document but my only problem is in find an algorithm that I should follow to fill in these tables!! so HOW!! I'm a bit confused??
0
 

Author Comment

by:lina000
ID: 10911624
Just wondering if XPath might solve this problem!!
Does anyone know how can I use XPath in Java?
0
 
LVL 7

Accepted Solution

by:
maheshexp earned 500 total points
ID: 10912081
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10912097
the java implementation is available from v1.5
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10912128
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10912134
freely avaible XPath interface for java

http://jaxen.org/
0
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10912249
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10914973
>> I used DOM class to parse the XML document but my only problem is in find an algorithm that I should follow to fill in these tables!! so HOW!! I'm a bit confused??
All you need to do now is walk the tree and add the data under the nodes to the respective tables in your database.

I don't think you would be served by using XPath as it is designed to point to an "address" in an XML document. You can certainly use it if you want.
0
 

Author Comment

by:lina000
ID: 10918999
Thanks all for replying!!
I guess my problem is with the logic it self (not the tools) I know using DOM or XPath will do it but the question is HOW can I implement such a thing!!
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10919411
It's a basic breadth-first tree traversal. Are you familiar with traversing hierarchical datastructures?
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10919656
u mean implement XPATH or DOM????

if i am right
here's a document to implement it

http://cafeconleche.org/books/xmljava/chapters/ch16.html
0
 

Author Comment

by:lina000
ID: 10922364
traversing hierarchical datastructures??
I'm not familiar with that!! how can this help??
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10965084
Actually, lina000 used knowledge aquired from this Q to post another. The answers provided here have helped in the pursuit of solving the overall problem. I vote no refund.
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10965281
lina000 got some documents for the references for XPATH, the answers provided here would solve her prolem somewhat....

i ubject to close this question
0
 

Author Comment

by:lina000
ID: 10986999
I guess you are right!! the provided documents had somehow helped!!
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10989396
thanks :-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question