nunopicado
nunopicado

Reputation: 307

Delphi: XML Data Binding (encoding)

I need to generate a XML file, and I have its schema in XSD format.

I created the classes using the XML Data Binding Wizard, but:

One of the requirements is that the xml has the encoding tag set to 'utf-8'.

I've done it before when creating xml's directly with IXMLDocument, by doing this:

var xml:IXMLDocument;
.
.
xml.Encoding:='utf-8';

The XML first line becomes < ? xml version="1.0" encoding="utf-8" ? >

But now, with the data binding wizard, I tried something similar:

var xml:IXMLAuditFile;
.
.
xml.OwnerDocument.Encoding:='utf-8';

But that encoding isn't showing in then xml file: < ? xml version="1.0" ? >

Is there any other place I should be setting the encoding when using the XML Data Binding?

Thank you Nuno

Upvotes: 3

Views: 1515

Answers (1)

nunopicado
nunopicado

Reputation: 307

Just found the answer to my own question.

When I display the generated XML in a TMemo, the encoding is not shown. But when I save it to a file, the encoding is added, as long as I have the xml.Encoding property set.

Thank you all.

Upvotes: 1

Related Questions