Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Expert One-on-One Access Application Development
This is the forum to discuss the Wrox book Expert One-on-One Microsoft Access Application Development by Helen Feddema; ISBN: 9780764559044
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Expert One-on-One Access Application Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 8th, 2013, 12:41 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default create xml file from Access 2003 database

trying to generate an xml file from within Access 2003 using VBA: new to xml coding, here is my code and output:
Code:
 and '*****************************************************************XML
     ' now lets do the info table as an xml file
     outputFileNum = FreeFile
      On Error GoTo errend
    Dim objDoc As MSXML2.DOMDocument
    Dim objNode As MSXML2.IXMLDOMNode
    Dim objRoot As MSXML2.IXMLDOMElement
    Dim objElem As MSXML2.IXMLDOMElement
    Set objDoc = New DOMDocument
    objDoc.resolveExternals = True
    Set objNode = objDoc.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'")
 
    Set objNode = objDoc.insertBefore(objNode, _
                                      objDoc.childNodes.Item(0))
  Set objRoot = objDoc.createElement("informationtable")
    
    Set objDoc.documentElement = objRoot
    
      objRoot.setAttribute "xml-stylesheet", " type=text/xsl href=INFO-TABLE_X01.xsl"
       'objRoot.setAttribute "xsi: schemaLocation", "http://www.sec.gov/edgar/document/thirteenf/informationtable eis_13FDocument.xsd"
      objRoot.setAttribute "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"
      objRoot.setAttribute "xmlns:n1", "http://www.sec.gov/edgar/document/thirteenf/informationtable"
      objRoot.setAttribute "xmlns", "http://www.sec.gov/edgar/document/thirteenf/informationtable"
    Set objDoc.documentElement = objRoot
     
    Set objNode = objDoc.insertBefore(objNode, _
                                      objDoc.childNodes.Item(1))
       
     
                                      
savethefile:
     objDoc.Save strSubmitFilenamexml
    xn = Shell("notepad.exe " & strSubmitFilenamexml, vbMaximizedFocus)
    Exit Sub
    
errend:
MsgBox err.Description

FMsgBox "There was an error creating the XML portion of the report.@@Check that you have 7 days of data. The reports will still be created.@" & err.Description
    GoTo savethefile
Exit Sub
toomany:
    FMsgBox "There was an error creating the XML portion of the report.@@Check the XML file and ensure that there is only 7 days of data."
     GoTo savethefile

End Sub
'************************************************* ****************XML
' now lets do the info table as an xml file
outputFileNum = FreeFile
On Error GoTo errend
Dim objDoc As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMNode
Dim objRoot As MSXML2.IXMLDOMElement
Dim objElem As MSXML2.IXMLDOMElement
Set objDoc = New DOMDocument
objDoc.resolveExternals = True
Set objNode = objDoc.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'")

Set objNode = objDoc.insertBefore(objNode, _
objDoc.childNodes.Item(0))
Set objRoot = objDoc.createElement("informationtable")

Set objDoc.documentElement = objRoot

objRoot.setAttribute "xml-stylesheet", " type=text/xsl href=INFO-TABLE_X01.xsl"
'objRoot.setAttribute "xsi: schemaLocation", "http://www.sec.gov/edgar/document/thirteenf/informationtable eis_13FDocument.xsd"
objRoot.setAttribute "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"
objRoot.setAttribute "xmlns:n1", "http://www.sec.gov/edgar/document/thirteenf/informationtable"
objRoot.setAttribute "xmlns", "http://www.sec.gov/edgar/document/thirteenf/informationtable"
Set objDoc.documentElement = objRoot

Set objNode = objDoc.insertBefore(objNode, _
objDoc.childNodes.Item(1))



savethefile:
objDoc.Save strSubmitFilenamexml
xn = Shell("notepad.exe " & strSubmitFilenamexml, vbMaximizedFocus)
Exit Sub

errend:
MsgBox err.Description

FMsgBox "There was an error creating the XML portion of the report.@@Check that you have 7 days of data. The reports will still be created.@" & err.Description
GoTo savethefile
Exit Sub
toomany:
FMsgBox "There was an error creating the XML portion of the report.@@Check the XML file and ensure that there is only 7 days of data."
GoTo savethefile

End Sub
************************************************** *

here is xml created:

<?xml version="1.0" encoding="UTF-8"?>
<informationtable xml-stylesheet=" type=text/xsl href=INFO-TABLE_X01.xsl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n1="http://www.sec.gov/edgar/document/thirteenf/informationtable" xmlns="http://www.sec.gov/edgar/document/thirteenf/informationtable"/>

************************************************** ****

here is the xml I need to create:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="INFO-TABLE_X01.xsl"?>
<informationTable xsi:schemaLocation="http://www.sec.gov/edgar/document/thirteenf/informationtable eis_13FDocument.xsd"
xmlns="http://www.sec.gov/edgar/document/thirteenf/informationtable"
xmlns:n1="http://www.sec.gov/edgar/document/thirteenf/informationtable"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<infoTable>
<nameOfIssuer>ISSUER NAME ONE</nameOfIssuer>
<titleOfClass>COM NEW</titleOfClass>
<cusip>373891034</cusip>
<value>42067</value>
<shrsOrPrnAmt n1:shrsPrnType="SH">804500</shrsOrPrnAmt>
<investmentDiscretion>SOLE</investmentDiscretion>
<otherManager>1</otherManager>
<votingAuthority>
<Sole>804500</Sole>
<Shared>0</Shared>
<None>0</None>
</votingAuthority>

Last edited by daurick; April 8th, 2013 at 12:49 PM. Reason: removed test messages. add code tags
Reply With Quote
  #2 (permalink)  
Old October 15th, 2015, 03:31 AM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2014
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Access 2003 Database file (.mdb) using VB6.0 rameshbabukasilingam Access 0 March 22nd, 2013 11:58 AM
Combine multiple xml files to create one xml file jonnyuk3 XSLT 6 March 29th, 2012 11:51 AM
Vb.Net 2003 : How to Open and Read an XML File to TEXT File. Lennie VS.NET 2002/2003 0 February 12th, 2010 04:18 PM
Access denied, can't create xml file from ASP.NET goldablasha C# 3 February 27th, 2007 04:50 AM
Access XML fragments embedded in Word 2003 debsoft General .NET 2 May 7th, 2004 07:55 AM



All times are GMT -4. The time now is 01:23 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.