1
votes

I cannot seem to be able to access an online XML file contents using the XSD and XML Data Binding Wizard. I need to update daily a database table with all the requested currencies from an online XML. I use Delphi XE and the XSD is located here: http://www.bnr.ro/nbrfxrates.xsd And the XML is this: http://www.bnr.ro/files/xml/years/nbrfxrates2013.xml

So I downloaded the XSD, and processed it with XML Data Binding wizard. This resulted in the unit nbrfxrates.

I need to be able to access a rate for a specific currency at a specific date, some function like for example

function getMyRate(date,currency):double;
begin
...
end; 

where I can provide a date and a currency and obtain the value from the XML.I have no idea how to do that.

The XML structure seems pretty simple but I am stuck at accessing it from Delphi... Please help me.

1

1 Answers

1
votes

You just need to load your file and access the nodes using the provided accessors, which are all basically Delphi standard classes with some magic to access the underlying DOM.

This is what I got after a couple of seconds of fiddling with your files.

procedure TForm1.Button1Click(Sender: TObject);
var
  obj: IXMLDataSet;
begin
  obj := LoadDataSet('D:\Downloads\nbrfxrates2013.xml');
  ShowMessage(obj.Body.Cube.Items[0].Date);
end;