IbrahimSA
asked on
HOW I CAN SHOW THE UTF-8 character using IXMLDocument component
hi all
i use the following code for parsing XML .... it works, however, it doesn't show the UTF-8 characters >>>instead it shows '????'
is there any way to show these UTF-8 Characters?
thank a lot
i use the following code for parsing XML .... it works, however, it doesn't show the UTF-8 characters >>>instead it shows '????'
is there any way to show these UTF-8 Characters?
thank a lot
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, ComCtrls, ExtCtrls,
XMLDoc, XMLIntf;
type
TForm1 = class(TForm)
Button3: TButton;
Memo1: TMemo;
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure PrintNode(ANode: IXMLNode);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.PrintNode(ANode: IXMLNode);
var cnt: Integer;
begin
if ANode.NodeType = ntElement then begin
Memo1.Lines.Add(ANode.NodeName);
if ANode.IsTextElement then
Memo1.Lines.Add(#9 + ANode.Text);
for cnt := 0 to ANode.AttributeNodes.Count - 1 do
Memo1.Lines.Add(ANode.AttributeNodes.Nodes[cnt].NodeName+'='+ VarToStr(ANode.AttributeNodes.Nodes[cnt].NodeValue));
for cnt := 0 to ANode.ChildNodes.Count - 1 do
PrintNode(ANode.ChildNodes.Nodes[cnt]);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var doc: IXMLDocument;
cnt: Integer;
node: IXMLNode;
begin
doc := LoadXMLDocument('aa1.xml');
for cnt := 0 to doc.ChildNodes.Count - 1 do begin
node := doc.ChildNodes.Nodes[cnt];
PrintNode(node);
end;
end;
end.
ASKER
I also added this command
doc := LoadXMLDocument(AnsiToUtf8 ('aa1.xml' ));
rather than
doc := LoadXMLDocument('aa1.xml)) ;
With NO success :(
doc := LoadXMLDocument(AnsiToUtf8
rather than
doc := LoadXMLDocument('aa1.xml))
With NO success :(
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
doc.encoding :='UTF-8';
and nothings changes :(
procedure TForm1.Button3Click(Sender
var
doc: IXMLDocument;
cnt: Integer;
node: IXMLNode;
begin
doc := LoadXMLDocument('aa1.xml')
doc.encoding :='UTF-8';
for cnt := 0 to doc.ChildNodes.Count - 1 do begin
node := doc.ChildNodes.Nodes[cnt];
PrintNode(node);
end;end;