p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: Expert One-on-One Access Application Development (http://p2p.wrox.com/book-expert-one-one-access-application-development-131/)
-   -   create xml file from Access 2003 database (http://p2p.wrox.com/book-expert-one-one-access-application-development/89804-create-xml-file-access-2003-database.html)

daurick April 8th, 2013 12:41 PM

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>

alva114 October 15th, 2015 03:31 AM

[8][}:)][}:)][}:)]


All times are GMT -4. The time now is 04:33 PM.

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