Ozzie, chuck this procedure into this directory, overwriting the old one. It was the
CreateXMLNode(RootXMLNode(*XmlTree)) code that needed an extra parameter to look like this to work under 5.31
CreateXMLNode(RootXMLNode(*XmlTree),"")
XIncludeFile "Modules\Export\_ExportDataItems.pbi" ; Export data data to a standard XML file
Code:
;==========================================================================================================================================================
; Export appointment data to a standard XML file
;==========================================================================================================================================================
Procedure ExportDataItems()
;------------------------------------------------------------------------------------------------
; Process the current table name and dump the contents to an XML file on disk
;------------------------------------------------------------------------------------------------
QueryString.s = "SELECT * FROM Keeper"
If DatabaseQuery(Program\DatabaseHandle, QueryString.s)
;----------------------------------------------------------------------------------------------
; Process the next returned row
;----------------------------------------------------------------------------------------------
While NextDatabaseRow(Program\DatabaseHandle)
;--------------------------------------------------------------------------------------------
; Have we created this XML tree already?
;--------------------------------------------------------------------------------------------
If *XmlTree = 0
*XmlTree = CreateXML(#PB_Any) ; Creates a new empty XML tree identified by the #XML number
*RootXmlNode = CreateXMLNode(RootXMLNode(*XmlTree),"") ; Creates a new XML node and inserts it into the given parent node.
SetXMLNodeName(*RootXmlNode, #Program) ; Changes the tagname of the given XML node (root in this case)
EndIf
;--------------------------------------------------------------------------------------------
; Creates a new XML node and inserts it into main XML node of the tree.
;--------------------------------------------------------------------------------------------
*RowNode = CreateXMLNode(MainXMLNode(*XmlTree),"")
;--------------------------------------------------------------------------------------------
; If the main node was created, dump all the columns using the column names as node names
;--------------------------------------------------------------------------------------------
If *RowNode
;------------------------------------------------------------------------------------------
; Get the column names and write them first
;------------------------------------------------------------------------------------------
NumberOfColumns.i = DatabaseColumns(Program\DatabaseHandle)
;------------------------------------------------------------------------------------------
; Iterate through the columns
;------------------------------------------------------------------------------------------
For ColumnNamesLoop.i = 0 To NumberOfColumns.i -1
CurrentColumn.s = DatabaseColumnName(Program\DatabaseHandle, ColumnNamesLoop.i)
*ColumnNode = CreateXMLNode(*RowNode,"") ; Creates a new XML node and inserts it into main XML node of the tree.
SetXMLNodeText(*ColumnNode, TextToXml(GetDatabaseString(Program\DatabaseHandle, ColumnNamesLoop.i)))
Next ; Next column
;------------------------------------------------------------------------------------------
; Main node wasn't created, exit out of this procedure
;------------------------------------------------------------------------------------------
Else
SetInfoBarArea("Headings", "Error", "Could not create the export data file.")
ProcedureReturn
EndIf
;--------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------
Wend
;----------------------------------------------------------------------------------------------
;
;----------------------------------------------------------------------------------------------
FinishDatabaseQuery(Program\DatabaseHandle)
;----------------------------------------------------------------------------------------------
;
;----------------------------------------------------------------------------------------------
If *XmlTree
FormatXML(*XmlTree, #PB_XML_ReFormat)
SaveXML(*XmlTree, Program\TemporaryDirectory + #Program + "_Export.xml")
FreeXML(*XmlTree)
SetInfoBarArea("Headings", "Info", "Data exported to " + Program\TemporaryDirectory)
EndIf
;----------------------------------------------------------------------------------------------
; The database query has failed for some reason
;----------------------------------------------------------------------------------------------
Else
SetInfoBarArea("Headings", "Error", "The database query failed or was empty. " + DatabaseError())
EndIf
;------------------------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------------------------
TextFileId.i = CreateFile(#PB_Any, Program\TemporaryDirectory + #Program + "_Export.txt")
;------------------------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------------------------
If TextFileId.i <> 0
;----------------------------------------------------------------------------------------------
;
;----------------------------------------------------------------------------------------------
If DatabaseQuery(Program\DatabaseHandle, "SELECT Title, Information FROM Keeper")
While NextDatabaseRow(Program\DatabaseHandle)
TitleString.s = KillQuote(GetDatabaseString(Program\DatabaseHandle, 0))
InformationString.s = KillQuote(GetDatabaseString(Program\DatabaseHandle, 1))
WriteStringN(TextFileId.i, "Title: " + TitleString.s)
WriteStringN(TextFileId.i, "")
WriteStringN(TextFileId.i, "Info: " + InformationString.s)
WriteStringN(TextFileId.i, "")
WriteStringN(TextFileId.i, "")
WriteStringN(TextFileId.i, "----------------------------------------------------------------------------------------------------")
Wend
FinishDatabaseQuery(Program\DatabaseHandle)
MessageRequester("Export finished", "Keeper XML data and text files have been saved in this directory:" + Chr(10) + Chr(13) + Chr(10) + Chr(13) + Program\TemporaryDirectory)
EndIf
;----------------------------------------------------------------------------------------------
;
;----------------------------------------------------------------------------------------------
CloseFile(TextFileId)
;----------------------------------------------------------------------------------------------
;
;----------------------------------------------------------------------------------------------
EndIf
;------------------------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------------------------
EndProcedure