<xmlDocument variable>.Save (Function)
In french: <Variable xmlDocument>.Sauve
Saves an XML document in a file.
If an XSD description was used, it is automatically used to validate the XML document when saved.
MyXMLDocument is xmlDocument
Filter is string = "XML files (*.xml)" + TAB + "*.xml" + CR + ...
"All files (*.*)" + TAB + "*.*"
OutputFile is string = fSelect("", "", "Select an XML file...", ...
Filter, "xml", fselCreate)
IF OutputFile <> "" THEN
IF ErrorOccurred = True THEN
ErrorBuild("An error occurred when saving: %1", ...
// The description of the XML file named "stream" was imported into the project.
// A blank XML file will be created from this description.
// The XML file does not physically exist yet.
// Load the XML content
MyXMLDoc is xmlDocument,description="stream"
MyXMLDoc.rss.Channel.Title = gsParamTitle
MyXMLDoc.rss.Channel.Link = gsParamSiteAddress
MyXMLDoc.rss.Channel.Description = gsParamSiteDescription
MyXMLDoc.rss.Channel.Copyright = gsParamCopyright
MyXMLDoc.rss.Channel.Webmaster = gsParamContactAddress
MyXMLDoc.rss.Channel.Image = gsParamURLSiteImage
MyXMLDoc.rss.Channel.Generator = "Easy RSS"
// Save the file
// Save the file with formatting (new feature of version 22)
<XML document>.Save([<File name and path>] [, <Options>])
<XML document>: xmlDocument variable
xmlDocument variable containing the document to save. This variable can be the result of a call to XMLOpen or it may have been declared and initialized directly.
<File name and path>: Optional ANSI or Unicode character string
Name and full (or relative) path of text file to create. A UNC path can be used.
If this parameter is not specified or if it is set to "" (empty string):
- When <xmlDocument variable>.Save is called for the first time on this document, the XML document is saved to the location specified when it was opened (XMLOpen).
- On subsequent calls to <xmlDocument variable>.Save, the XML document is saved to the location specified the last time it was saved.
- An error occurs if the XML document was not opened by XMLOpen (opened from a URL, from a string or if the document was created).
<Options>: Optional Integer constant
Options for saving the XML document.
The possible values are:
When describing an XML document, you have the ability to specified the XSD file that will be used as validation model for the XML file. For example:
cMyDoc is xmlDocument <description="person.xsd">
By default, this XSD file is taken into account when saving the document: the validity of the document is automatically checked before saving the XML document (equivalent to <xmlDocument variable>.ValidDocument
). To avoid performing this validation, all you have to do is used the xvNoValidation
This page is also available for…