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 Visual BasicSource Code Listing ' Iterate over the ArticleTitles beginning with "M"
' using FindNextRecord. Move these records from
' the input XML document to the output XML document.
Private Sub Command6_Click()
Label6.Caption = "Working..."
Label6.Refresh
Dim xmlDoc As New ChilkatXml
Dim outXml As New ChilkatXml
Dim rec1 As ChilkatXml
Dim rec2 As ChilkatXml
outXml.Tag = "MRecords"
' Load the input document.
xmlDoc.LoadXmlFile "crisp.xml"
' Find the first article beginning with M
Set rec1 = xmlDoc.FirstChild()
' If rec1 matches, it returns itself.
Set rec1 = rec1.FindNextRecord("ArticleTitle", "M*")
Do While Not (rec1 Is Nothing)
' Continue the search with the next sibling.
Set 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 Not (rec2 Is Nothing) Then
Set rec1 = rec2.FindNextRecord("ArticleTitle", "M*")
Else
Set rec1 = Nothing
End If
Loop
' Save the output document.
outXml.SaveXml "MRecords.xml"
' The original document is now without articles
' beginning with M
xmlDoc.SaveXml "MissingMRecords.xml"
Label6.Caption = "Done."
End Sub
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.