Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access and DOM

Status
Not open for further replies.

Kadirpatel

Programmer
Mar 28, 2001
43
GB
Hi All,
I need some help on DOM to create XML files. I'm using MS-Access as backend and want to create XML file depending on the table. Then after taking the information from the XML files I want to make HTML pages. Now I need ur help on first part that is how to construct the XML files from database using DOM and JAVA. Please help me as fast as possible.

Thanks. :)
 
Hi.

You should use DAO or ADO to read datas from your Access DB. I think, you have to download MSXML3.0 to use the most up to date DOM from MSDN Microsoft / XML ( ) Read datas from Access and write to XMLDOM. To display the XML on the web you should use XSL. I don't know how detailed information you need.

regards, Kirilla
 
Thanks Kirilla for ur reply. My actual reqiurement is some site or some example to build XML file from a database. The other part of connection with database and all will be done by me. But I just needed a sample code to build an XML corresponding to the table using DOM. So please if u can do so, I'll b greateful to u.
 
Hi.

Here is some part of my code that writes data to an XML database. If you need more, give me your email and we can discuss it.

import java.io.*;
import java.util.Date;
import msxml3.*;
import com.ms.wfc.ui.MessageBox;
import com.ms.com.Variant;
import msmapi32.MAPISession;
import msmapi32.MAPIMessages;

private FileOutputStream fOut;
private PrintWriter pwOut;
private final String devXML="c:\\wc_web\\devwc.xml";
private final String transXML="c:\\wc_web\\transXML.xml";

private String sDate;
private String[] aElements=new String[50];

private void writeTo_XML(String swCount,String sPath)
{
try{
if(this.chkswCount(swCount))
{
DOMDocument xmlDoc=new DOMDocument();
Variant xmlPath=new Variant(sPath);
xmlDoc.setAsync(false);
xmlDoc.load(xmlPath);
IXMLDOMElement xElement;
IXMLDOMNode xNode,xNodeClone;
xElement=xmlDoc.getDocumentElement();
xNode=xElement.getLastChild();
xNodeClone=xNode.cloneNode(true);
xElement.appendChild(xNodeClone);
xNode=xElement.getLastChild();
Variant vValue=new Variant(sDate);
xNode.getAttributes().getNamedItem("datestamp").setNodeValue(vValue);
for(int ii=0;ii<xNode.getChildNodes().getLength();ii++)
{
vValue.putString(aElements[ii]);
xNode.getChildNodes().getItem(ii).setNodeTypedValue(vValue);
}
xmlDoc.save(xmlPath);

}
}catch(Exception ex){
this.sendMail(ex.getMessage().toString());
}
}

Some part of the XML file:
..
<modul datestamp=&quot;Opening Balance&quot;>
<DDF>465</DDF>
<DLL>0</DLL>
<MENUTRA>42</MENUTRA>
<DI>0</DI>
<GL>124</GL>
<HR>0</HR>
<MA>0</MA>
<MP>707</MP>
<OR>700</OR>
<PA>209</PA>
<PC>216</PC>
<PL>5724</PL>
<PN>2339</PN>
<PR>52</PR>
<SC>172</SC>
<SL>4673</SL>
<SM>94</SM>
<ST>0</ST>
<SY>743</SY>
</modul>


<modul datestamp=&quot;2001-2-5&quot;>
<DDF>3</DDF>
<DLL>0</DLL>
<MENUTRA>0</MENUTRA>
<DI>0</DI>
<GL>149</GL>
<HR>0</HR>
<MA>0</MA>
<MP>243</MP>
<OR>133</OR>
<PA>0</PA>
<PC>0</PC>
<PL>1618</PL>
<PN>0</PN>
<PR>24</PR>
<SC>0</SC>
<SL>277</SL>
<SM>1</SM>
<ST>0</ST>
<SY>58</SY>
</modul>
..

regards, Kirilla
 
Thanx Kirilla I think that this code will solve my purpose. I'll definitely try it out. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top