System.XML is working

System.XML is working

CrossTalk is now advanced enough that it can use XmlReader in System.XML to read XML data.

procedure TestXML();
var
  xSettings: XmlReaderSettings;
  xReader: XmlReader;
begin
  xSettings := XmlReaderSettings.Create; try
    xSettings.ConformanceLevel := ConformanceLevel.Fragment;
    xSettings.IgnoreWhitespace := true;
    xSettings.IgnoreComments := true;
    xReader := XmlReader.Create(
     ‘C:sourceCrossTalksourceTestLefttest.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;

Notice its all standard Delphi code. In fact it is a straight translation of a C# example.

XmlReader.Create

XmlReader.Create is actually a static method in .NET called Create and CrossTalk has translated it exactly as that. It is just coincidence that Delphi uses Create for its construtors. Normally you would call Create to access the constructor, but XmlReader does not work this way because that is not how it works in .NET either.