Hi,

> I want to extract the data out of the XML file and do two things. Firstly I have
> to put it into data-structure defined by me so that I can pass the data to other
> modules. But I get your point that instead of making my own data-structures I
> could use part of the DOM in memory.  But I still need to know how to access the
> DOM tree.
> Seconldy I have to store all the data in the database. Hence I was looking for
> some code which would give me a clue of getting the data and storing it into the
> database. In simple words I was looking for code with the help of which I can
> traverse the DOM tree and extract the data.

The xerces-c DOM API which you can get from xml.apache.org will provide 
details of how to traverse a DOM tree. You will then have to write your 
database code and insert the values you want from the nodes. There are 
some example programs with the download you can look at as well.


> > 2)Suggest which would be a better approach SAX or DOM? Note that I donot want
> to
> > manipulate the data. I just want to extract the data and put it into data
> > structures. I guess SAX would be faster.
> 
> ---SAX will probably be faster if you don't need the overhead of a complete
> ---DOM in memory. What kind of data are you trying to extract from the XML
> ---file?
> 


I would probably take the SAX approach. There are some examples in the 
download of how to override the appropriate methods. For example, you could 
override the startElement method and place a switch on the element name to 
insert into different database tables. 

Gareth

-- 
Gareth Reakes, Head of Product Development  
DecisionSoft Ltd.            http://www.decisionsoft.com
Office: +44 (0) 1865 203192



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to