XMLDocument.SaveXML

From Xojo Documentation

Method

XMLDocument.SaveXML(fItem As FolderItem)

Supported for all project types and targets.

Saves the XML to the passed FolderItem.

Example

The following XML, stored in a constant called kXMLTest, is saved to a file selected by the user:

 <?xml version="1.0" encoding="UTF-8"?>
 <League>
 	<Team name="Seagulls">
 		<Player name="Bob" position="1B" />
 		<Player name="Tom" position="2B" />
 	</Team>
 	<Team name="Pigeons">
 		<Player name="Bill" position="1B" />
 		<Player name="Tim" position="2B" />
 	</Team>
 	<Team name="Crows">
 		<Player name="Ben" position="1B" />
 		<Player name="Ty" position="2B" />
 	</Team>
 </League>
Dim saveFile As FolderItem
saveFile = GetSaveFolderItem("", "Test.xml")

If saveFile <> Nil Then
Dim xml As New XmlDocument
Try
xml.LoadXml(kTestXml)

xml.SaveXml(saveFile)

If saveFile.LastErrorCode <> 0 Then
MsgBox("Save error: " + Str(saveFile.LastErrorCode))
End If
Catch e As XmlException
MsgBox("XML error: " + e.Message)
End Try
End If