Working with XML in Delphi (returning certain data to a variable)

I have been trying to work with Delphi 2010 and MSXML for the past few days, I am an extreme beginner and need a little direction.

var
    MemoryStream: TMemoryStream;
    XMLPath: String;
    sName: String;
    XMLDoc: variant;
    doc: TStringList;
begin
  //unrelated code
  // Create XML File to hard disk
    begin
        MemoryStream := TMemoryStream.Create;

        IdHTTP1.get('http://somewebsite' + , MemoryStream);
        MemoryStream.Position := 0;
        MemoryStream.SaveToFile('data.xml');
        MemoryStream.Free;

    end;
    // Load XML file for data display

    doc:=TStringList.Create;
    doc.LoadFromFile('data.xml');

    XMLDoc := CreateOleObject('Msxml2.DOMDocument.6.0');
    XMLDoc.async := false;
    XMLDoc.LoadXML(doc.Text);

As you can see, I can load the data into an XML file on the hard drive, then load this file into DomDocument. I am stuck from now ... I want to use this data as I would make a set of records in ADO (e.g. SomeVariable: = rs.Fields.Item ('DesiredData'). Value). I did some research and read some methods. However, I cannot understand this. I know that this has become something trivial, I am not far enough to understand this.

There seem to be many good examples of how to write to an XML file, but none of them use data.

+3
2

, - :

someNode := XMLDoc.selectSingleNode('//route/to/node');
str := someNode.text;

selectSingleNode XPath, : //route/to/node/@attrib

MSDN selectSingleNode: http://msdn.microsoft.com/en-us/library/ms757846(v=VS.85).aspx XPint sintax: http://msdn.microsoft.com/en-us/library/ms256471(v=VS.85).aspx

, XML- XML Manipulation Delphi, MSXML, : http://www.omnixml.com/

, XML , XML, XML XSD ( XML , , ): http://www.youtube.com/watch?v=4D78MG4CaAI&feature=player_embedded

+5

XML (, ), SimpleStorage - , . :

http://www.cromis.net/blog/downloads/simplestorage/

OmniXML XML. SimpleStorage XML.

+1

Source: https://habr.com/ru/post/1761835/


All Articles