Patch Method (XmlDocument, XmlReader)

Microsoft XML Diff

Microsoft XML Diff 1.0 and XML Patch 1.0

XmlPatch.Patch Method (XmlDocument, XmlReader)

Modifies the document in the XmlDocument by applying the XDL Diffgram parsed by an XmlReader.

[Visual Basic]
Overloads Public Sub Patch( _
  ByVal sourceDoc As XmlDocument, _
  ByVal diffgram As XmlReader _
)
[C#]
public void Patch(
  XmlDocument sourceDoc,
  XmlReader diffgram
);

Parameters

sourceDoc
An XmlDocument containing the source document to be modified.
diffgram
The XDL Diffgram that is parsed by the XmlReader to apply to the source document.

Example

The following code sample loads a source document and an XDL Diffgram, and saves the changed sourceDoc into a new file called changed_doc.xml.

[Visual Basic]
Imports System
Imports System.IO
Imports System.Xml
Imports Microsoft.XmlDiffPatch

Public Class Sample

   Public Shared Sub Main()
      Dim sourceDoc As New XmlDocument()
      sourceDoc.Load("source.xml")
      Dim myPatch As New XmlPatch()
      Dim myRdr As New XmlTextReader("diffgram.xml")
      myPatch.Patch(sourceDoc, myRdr)
      sourceDoc.Save("changed_doc.xml")
   End Sub 'Main
End Class 'Sample 
[C#]
using System;
using System.IO;
using System.Xml;
using Microsoft.XmlDiffPatch;

public class Sample 
{
    public static void Main() 
    {
        XmlDocument sourceDoc = new XmlDocument();
        sourceDoc.Load("source.xml");
        XmlPatch myPatch = new XmlPatch();
        XmlTextReader myRdr = new XmlTextReader("diffgram.xml");
        myPatch.Patch(sourceDoc, myRdr);
        sourceDoc.Save("changed_doc.xml");
    }
}

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP, Windows .NET Server

See Also

XmlPatch Class | XmlPatch Members | Microsoft.XmlDiffPatch

© 2002 Microsoft Corporation. All rights reserved.