Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Decode HTML Entities found in XML
Demonstrates how to decode HTML entities found in XML.Chilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Xml;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
xml: TXml;
strDecoded: string;
begin
success := False;
// Load an XML file containing the following:
// <?xml version="1.0" encoding="UTF-8"?>
// <output>Französische</output>
xml := TXml.Create;
success := xml.LoadXmlFile('qa_data/xml/hasHtmlEntity.xml');
// Get non-decoded content, then get decoded content.
// Result is Französische
WriteLn(xml.Content);
// Result is Französische
strDecoded := xml.DecodeEntities(xml.Content);
WriteLn(strDecoded);
xml.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.