The following example demonstrates usage of the .NET XmlReader class. It is a direct translation of a C# example.

procedure TestXML();
var
  xSettings: XmlReaderSettings;
  xReader: XmlReader;
begin
  xSettings := XmlReaderSettings.Create; try
    xSettings.ConformanceLevel := ConformanceLevel.Fragment;
    xSettings.IgnoreWhitespace := true;
    xSettings.IgnoreComments := true;
    xReader := XmlReader.Create2('C:\source\CrossTalk\source\TestLeft\test.xml', xSettings);
    try
      while not xReader.EOF do begin
        if (xReader.MoveToContent = XmlNodeType.Element)
         and (xReader.Name = 'ProductName') then begin
          WriteLn('Product: ' + xReader.ReadString);
        end;
        xReader.Read();
      end;
      xReader.Close;
    finally xReader.Free; end;
  finally xSettings.Free; end;
end;

end;

XmlReader.Create

XmlReader.Create is actually a static method in .NET called Create and not the consructor. C# does not use the keyword Create for constructors. To avoid conflict with the commonly used Create name in Delphi for most constructors, CrossTalk will alias any method named Create to Create2. That is why in the above example Create2 is used instead of Create.

In this example, Create is a class factory and not a constructor.