Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Find Matching XML Records in Delphi Source Code Listing // Iterate over the ArticleTitles beginning with 'M'
// using FindNextRecord. Move these records from
// the input XML document to the output XML document.
procedure TForm1.Example6Click(Sender: TObject);
var
xmlDoc: IChilkatXml;
outXml: IChilkatXml;
rec1: IChilkatXml;
rec2: IChilkatXml;
begin
xmlDoc := CoChilkatXml.Create();
outXml := CoChilkatXml.Create();
outXml.Tag := 'MRecords';
// Load the input document.
xmlDoc.LoadXmlFile('crisp.xml');
// Find the first article beginning with M
rec1 := xmlDoc.FirstChild();
// If rec1 matches, it returns itself.
rec1 := rec1.FindNextRecord('ArticleTitle','M*');
while (rec1 <> nil) do
begin
// Continue the search with the next sibling.
rec2 := rec1.NextSibling();
// This has the effect of removing the subtree rooted
// at rec from xmlDoc, and adding it to outXml
outXml.AddChildTree(rec1);
if (rec2 <> nil) then
rec1 := rec2.FindNextRecord('ArticleTitle','M*')
else
rec1 := nil;
end;
// Save the output document.
outXml.SaveXml('MRecords.xml');
// The original document is now without articles
// beginning with M
xmlDoc.SaveXml('MissingMRecords.xml');
end;
end.
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.