Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
SearchAllForContent
See more XML Examples
Demonstrates the SearchAllForContent method.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;
xBeginAfter: TXml;
xFound: TXml;
searchForMore: Boolean;
begin
success := False;
xml := TXml.Create;
success := xml.LoadXmlFile('qa_data/xml/pigs.xml');
if (success <> True) then
begin
WriteLn(xml.LastErrorText);
Exit;
end;
xBeginAfter := xml.GetSelf();
xFound := xml.SearchAllForContent(xBeginAfter,'*pig*');
searchForMore := True;
while (searchForMore = True) do
begin
WriteLn(xFound.Tag);
WriteLn(xFound.Content);
WriteLn('--');
xBeginAfter.Free;
xBeginAfter := xFound;
xFound := xml.SearchAllForContent(xBeginAfter,'*pig*');
searchForMore := xml.LastMethodSuccess;
end;
xBeginAfter.Free;
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.