System.XML is working
CrossTalk is now advanced enough that it can use XmlReader in System.XML to read XML data.
xSettings := XmlReaderSettings.Create; try
xSettings.ConformanceLevel := ConformanceLevel.Fragment;
xSettings.IgnoreWhitespace := true;
xSettings.IgnoreComments := true;
xReader := XmlReader.Create(
while not xReader.EOF do begin
if (xReader.MoveToContent = XmlNodeType.Element)
and (xReader.Name = ‘ProductName’) then begin
WriteLn(‘Product: ‘ + xReader.ReadString);
finally xReader.Free; end;
finally xSettings.Free; end;
Notice its all standard Delphi code. In fact it is a straight translation of a C# example.
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.