Solved

Filling tables with XML data

Posted on 2004-04-24
21
306 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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: 10912134
freely avaible XPath interface for java

http://jaxen.org/
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

707 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