Converts the contents of the specified XML object to a UTF-8 XML document and saves it to a file.

Syntax

bool XML_SaveAsXmlFile(
  XML_HANDLE hXml,
  const char *prolog,
  const char *filename,
  bool format,
  int *ErrCode
);

Parameters

hXml
[in] XML handle
prolog
[in] A pointer to the UTF-8 string of the "prolog" for the XML document. Specify NULL if "prolog" is not required.

filename
[in] A pointer to a file name string.
format
[in] Specify true if you want to format the XML document with line breaks and TAB indentation, otherwise specify false.
ErrCode
[out] A pointer to a variable that returns an error code. Specify NULL when no error code is required.

Return value

Returns true if the function succeeds, false otherwise.

Remarks

Converts the contents of the XML object specified by hXml to a UTF-8 XML document and saves it in the file specified by filename.

If you specify a UTF-8 string in prolog , the specified string is output at the beginning of the file. It is used to output XML declaration etc.

If the function fails, it returns false and ErrCode returns the following error code:

Error codeDescription
XML_INVALID_PARAMETER_ERRORParameter error
XML_MEMORY_ALLOCATION_ERRORMemory allocation error
XML_FILE_ERRORFile error
XML_INVALID_XML_OBJECT_ERRORInvalid XML handle

Requirements

Header file:
XML.h
CodeConversion.h : ver. 1.1.1 or later.
Library file:
libXML.a
libCodeConversion.a : ver.1.1.1 or later
libSTARTUPOPH5000.a

Sample

  
XML_SaveAsXmlFile(hXml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "RESULT.XML", true, &ErrCode);

See also

Last updated: 2021/10/21