Jump to content
Marty001

Data Binding retreiving data from list

Recommended Posts

I have an XML file produced by Media Companion for a movie, I have used the Data Binding wizard to produce a schema from a dtd file.  I can retrieve almost all the details from the file except when there is a list.
 

 <uniqueid type="tmdb">745272</uniqueid>
 <uniqueid type="imdb" default="true">tt13095604</uniqueid>

How do I retreive the value for uniqueid>imdb I cannot find any assistance via google that explains this situation.  Or am I missing something really simple

I have attached the files 
The Phenomenon (2020).nfo is the XML file
cm_movieinfo.dtd is the Document Schema
cm_movieinfo.xdb is the generated Delphi Data Binding Unit.

cm_movieinfo.dtd

The Phenomenon (2020).nfo

cm_movieinfo.xdb

Share this post


Link to post
10 hours ago, Marty001 said:

I have an XML file produced by Media Companion for a movie, I have used the Data Binding wizard to produce a schema from a dtd file.  I can retrieve almost all the details from the file except when there is a list.
 


 <uniqueid type="tmdb">745272</uniqueid>
 <uniqueid type="imdb" default="true">tt13095604</uniqueid>

How do I retreive the value for uniqueid>imdb I cannot find any assistance via google that explains this situation.  Or am I missing something really simple

I have attached the files 
The Phenomenon (2020).nfo is the XML file
cm_movieinfo.dtd is the Document Schema
cm_movieinfo.xdb is the generated Delphi Data Binding Unit.

cm_movieinfo.dtd

The Phenomenon (2020).nfo

cm_movieinfo.xdb

If you use the LoadMovie function in the code unit generated by the wizard you get an IXMLMovieType interface back. Its Uniqueid property returns an interface of type IXMLUniqueidTypeList, which derives from IXMLNodeCollection, so it represents a list of nodes (represented by IXMLUniqueidType interfaces), accessed via the Items property. The list interface inherits a Count property from IXMLNodeCollection, so you can write a classical for loop to iterate over the Items property to examine each of the UniqueId nodes, to find the one with the Type_ property you are looking for (note the underscore added to the property name by the wizard, to avoid a collision with the reserved word type).

Share this post


Link to post

Thanks for that information, I have managed to get the value, however using Loadmovie came up with 'interface not allowed' I changed back to 'Getmovie' and the following code works

  cmmovieinfo := Getmovie(XMLDocument1);

  for t := 0 to cmmovieinfo.Uniqueid.Count - 1 do
  begin
    if cmmovieinfo.Uniqueid[t].Type_ = 'imdb' then
      moviecode := cmmovieinfo.Uniqueid[t].nodevalue;
  end;

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×