TXMLDocumentRefresh (Delphi)
Description
The following example uses the Refresh function. An XML file is manipulated with 2 variables of type IXMLDocument: one writer and one reader.
Code
procedure Test_Refresh;
var
LDocumentWr: IXMLDocument;
LDocumentRd: IXMLDocument;
begin
{ Create an XML file. }
LDocumentWr := TXMLDocument.Create(nil);
LDocumentWr.Active := True;
LDocumentWr.DocumentElement := LDocumentWr.CreateNode('TestElement',
ntElement);
LDocumentWr.SaveToFile(DestPath);
{ Load the XML file into memory. Display the XML text. }
LDocumentRd := TXMLDocument.Create(nil);
LDocumentRd.LoadFromFile(DestPath);
Writeln(LDocumentRd.XML.Text);
{ Modify the XML file. }
LDocumentWr.DocumentElement.Text := 'Update.';
LDocumentWr.SaveToFile(DestPath);
{ Refresh the image of XML file in memory.
The XML text should contain the word 'Update'. }
LDocumentRd.Refresh;
Writeln('Refreshing...' + sLineBreak);
Writeln(LDocumentRd.XML.Text);
end;
Uses
- Xml.XMLDoc.TXMLDocument.CreateNode ( fr | de | ja )
- Xml.XMLDoc.TXMLDocument.SaveToFile ( fr | de | ja )
- Xml.XMLDoc.TXMLDocument.LoadFromFile ( fr | de | ja )
- Xml.XMLDoc.TXMLDocument.Refresh ( fr | de | ja )
- Xml.XMLDoc.TXMLDocument.XML ( fr | de | ja )