Page 1 of 1
XML Problem
Posted: 2012-07-12 18:41:42
by I-Catch
hi
today i was writing a script for the android and iphone app
http://www.netwalkapps.com/app/movielicious-android
and because the app has an import funktion i want to write a script to export my data (here are the specifications
http://www.netwalkapps.com/movies-xml-format )
here is the which i wrote:
Code: Select all
program MovieliciousExporter;
var
xmldata,curitem:string;
xml:TJvSimpleXml;
const
savepath = 'Z:\media\Daten_2TB\';
procedure getdata;
begin
Xml.Root.Items.Add('movie');
Xml.root.items.getitemnamed('movie').items.add('MovieID');
Xml.root.items.getitemnamed('movie').items.add('title');
Xml.root.items.getitemnamed('movie').items.add('media');
Xml.root.items.getitemnamed('movie').items.add('genre');
Xml.root.items.getitemnamed('movie').items.add('year');
Xml.root.items.getitemnamed('movie').items.add('mpaa');
Xml.root.items.getitemnamed('movie').items.getitemnamed('MovieID').value:=getfield(fieldnumber);
Xml.root.items.getitemnamed('movie').items.getitemnamed('title').value:=getfield(fieldtranslatedtitle);
Xml.root.items.getitemnamed('movie').items.getitemnamed('media').value:=getfield(fieldnumber);
Xml.root.items.getitemnamed('movie').items.getitemnamed('genre').value:=getfield(fieldCategory);
Xml.root.items.getitemnamed('movie').items.getitemnamed('year').value:=getfield(fieldyear);
Xml.root.items.getitemnamed('movie').items.getitemnamed('mpaa').value:=getcustomfield('fsk');
xmldata:=xml.savetostring;
end;
begin
xml:= TJvSimpleXml.create(nil);
//xml2:=
if xml.root.name='' then xml.root.name:= 'XMM_Movie_Database';
//Xml.Root.Items.Add('movie')
//Xml.Root.Items.Add('movie')
//a:=Xml.Root.GetChildIndex(Xml.root.items.getitemnamed('movie'));
//xmldata:=xml.savetostring;
getdata;
curitem:=curitem+xmldata;
showmessage(curitem);
end.
the problem is now that it worked for one movie but if i selced more than it lokk like
Code: Select all
<?xml version="1.0" encoding="iso-8859-1"?>
<XMM_Movie_Database>
<movie>
<MovieID>1</MovieID>
<title>(Traum)Job gesucht</title>
<media>1</media>
<genre>Komödie, Liebe/Romantik</genre>
<year>2009</year>
<mpaa>o.A.</mpaa>
</movie>
</XMM_Movie_Database>
<?xml version="1.0" encoding="iso-8859-1"?>
<XMM_Movie_Database>
<movie>
<MovieID>2</MovieID>
<title>2 Fast 2 Furious</title>
<media>2</media>
<genre>Action</genre>
<year>2003</year>
<mpaa>ab 16 Jahren</mpaa>
</movie>
</XMM_Movie_Database>
so the root node is double
i hope someone can help me and know what i mean
Posted: 2012-07-12 20:04:56
by antp
The problem is that you recreate the XML object each time: you should create it only if it is equal to nil.
So it will be kept between movies.
Each time instead of curitem:=curitem+xmldata; you can simply keep "xmldata" which should grow by itself if you do not recreate the xml object.
I guess that instead of show it the next step would be writing it to a file.
The downside is that the file will be written at each movie, but it is not a big problem (it will not affect the result).
Posted: 2012-07-12 22:34:59
by soulsnake
Hi,
This code bellow should work in AMC 4.1.0.2 or more.
Code: Select all
program MovieliciousExport;
var
xml: TJvSimpleXml;
const
savepath = 'Z:\media\Daten_2TB\MovieliciousExport.xml';
//savepath = 'C:\Users\snake\Desktop\MovieliciousExport.xml';
procedure AddMovieData;
var
eMovie: TJvSimpleXmlElem;
begin
xml.Root.Items.Add('movie');
eMovie := xml.Root.Items.GetItemNamed('movie');
eMovie.Items.Add('MovieID');
eMovie.Items.GetItemNamed('MovieID').value := GetField(fieldnumber);
eMovie.Items.Add('title');
eMovie.Items.GetItemNamed('title').value := GetField(fieldtranslatedtitle);
eMovie.Items.Add('media');
eMovie.Items.GetItemNamed('media').value := GetField(fieldnumber);
eMovie.Items.Add('genre');
eMovie.Items.GetItemNamed('genre').value := GetField(fieldCategory);
eMovie.Items.Add('year');
eMovie.Items.GetItemNamed('year').value := GetField(fieldyear);
eMovie.Items.Add('mpaa');
eMovie.Items.GetItemNamed('mpaa').value := GetCustomField('fsk');
end;
begin
if GetIteration = 0 then // First iteration
begin // We prepare XML
xml := TJvSimpleXml.create(nil);
xml.Root.Name := 'XMM_Movie_Database';
end;
// We add movie data
AddMovieData;
if GetIteration = GetIterationCount - 1 then // Last iteration
begin // We save XML to file and we close it
xml.SaveToFile(savepath)
xml.Free
end;
end.
Soulsnake.
---------------------------------------------------------------------
PS: I found a bug.
The code bellow should work but it doesn't.
It returns a type mismatch error on eMovie and eField.
Why ? In program source code, the class TJvSimpleXmlElemClassic is declared but after "Add" function, that why the error occurs.
This problem will be fixed in next update 4.1.1 and the code bellow will work correctly.
Code: Select all
program MovieliciousExport;
var
xml: TJvSimpleXml;
const
savepath = 'Z:\media\Daten_2TB\MovieliciousExport2.xml';
//savepath = 'C:\Users\snake\Desktop\MovieliciousExport2.xml';
procedure AddMovieData;
var
eMovie, eField: TJvSimpleXmlElemClassic; // or TJvSimpleXmlElem
begin
eMovie := xml.Root.Items.Add('movie'); // Doesn't work
eField := eMovie.Items.Add('MovieID'); // Doesn't work
eField.value := GetField(fieldnumber);
eField := eMovie.Items.Add('title');
eField.value := GetField(fieldtranslatedtitle);
eField := eMovie.Items.Add('media');
eField.value := GetField(fieldnumber);
eField := eMovie.Items.Add('genre');
eField.value := GetField(fieldCategory);
eField := eMovie.Items.Add('year');
eField.value := GetField(fieldyear);
eField := eMovie.Items.Add('mpaa');
eField.value := GetCustomField('fsk');
end;
begin
if GetIteration = 0 then // First iteration
begin // We prepare XML
xml := TJvSimpleXml.Create(nil);
xml.Root.Name := 'XMM_Movie_Database';
end;
// We add movie data
AddMovieData;
if GetIteration = GetIterationCount - 1 then // Last iteration
begin // We save XML to file and we close it
xml.SaveToFile(savepath)
xml.Free
end;
end.
Soulsnake.
Posted: 2012-07-13 11:46:12
by I-Catch
hi
thanks soulsnake that worked for me but is there an option to change the encoding to utf-8 and not iso-8859-1
mfg
ps i think there is a bug in the AddNewMovieToQueue. becuase when i use it adds lots off new movie instead of one.
Posted: 2012-07-13 12:54:15
by soulsnake
is there an option to change the encoding to utf-8 and not iso-8859-1
No, but you can open the generated file with notepad++ or other editor to convert file into utf-8.
ps i think there is a bug in the AddNewMovieToQueue. becuase when i use it adds lots off new movie instead of one.
I think it is not a bug but a bad use of this function.
This function have to be called very carefully.
You have to understand you execute the same code for each selected movie.
So if you put the function like this without any test, you produce an infinite loop. Why ? You call this function for each selected movie + the new movies you added with this function + new movies added by new movies + ... so you produce an infinite loop.
You have to use global variables and script functions to do some tests.
Here is a simple example how to use this function.
You have to select at least one movie in list to run this code :
Code: Select all
program AddNewMovies;
const
nbNewMovies = 100; // Number of new movies to add
var
newMovieStart: Integer;
i: Integer;
begin
if GetIteration = 0 then // First iteration
begin
newMovieStart := GetIterationCount;
for i := 0 to nbNewMovies - 1 do
begin
AddNewMovieToQueue;
end;
end
else if GetIteration >= newMovieStart then // One of new movies added
begin
// Number of new movie
i := GetIteration - newMovieStart + 1;
// Set title of new movie
SetField(fieldOriginalTitle, 'Movie N°' + IntToStr(i));
end;
end.
PS: I see a little bug, movie number is not correct.
It is the max(numbers) instead of max(numbers) + 1.
This will be fixed in next update.
Soulsnake.
Posted: 2012-07-14 14:01:51
by antp
For the UTF8 you could encode all texts using UTF8Encode, but I am not sure it is possible to set the character set info in the file header
Posted: 2012-07-19 08:30:34
by I-Catch
thank i got it working
here is the script if someone need it (maybe you have custumize it to your customfields)
Code: Select all
program MovieliciousExport;
uses
SoulSnakeUtils ;
var
xml: TJvSimpleXml;
exportxml,batch:tstringlist;
convert,actorsvalue:string;
const
savepath = 'Z:\media\Daten_2TB\movies\';
//savepath = 'C:\Users\snake\Desktop\MovieliciousExport.xml';
function ActorsToXml(actors: string): string;
var
lstActor: TStringList;
iActor,startpos: Integer;
sActor,name: string;
begin
lstActor := TStringList.Create;
lstActor.Text := stringreplace(actors,', ',#13#10);
for iActor := 0 to lstActor.Count - iActor do
begin
startpos:= pos(' (',lstActor.GetString(iActor));
name:=copy(lstActor.GetString(iActor),0,startpos-1);
sActor := ', ' + name ;
if lstActor.GetString(iActor) <> #13#10 then lstActor.SetString(iActor, sActor);
end;
Result := lstActor.Text;
lstActor.Free;
end;
procedure AddMovieData;
var
eMovie: TJvSimpleXmlElem;
seen:string;
begin
xml.Root.Items.Add('Movie');
eMovie := xml.Root.Items.GetItemNamed('Movie');
eMovie.Items.Add('MovieID');
eMovie.Items.GetItemNamed('MovieID').value := GetField(fieldnumber);
eMovie.Items.Add('Title');
eMovie.Items.GetItemNamed('Title').value := GetField(fieldtranslatedtitle);
eMovie.Items.Add('Media');
eMovie.Items.GetItemNamed('Media').value := GetField(fieldVideoFormat);
eMovie.Items.Add('Genres');
eMovie.Items.GetItemNamed('Genres').value := GetField(fieldCategory);
eMovie.Items.Add('Year');
eMovie.Items.GetItemNamed('Year').value := GetField(fieldyear);
eMovie.Items.Add('MPAA');
eMovie.Items.GetItemNamed('MPAA').value := GetCustomField('fsk');
eMovie.Items.Add('Country');
eMovie.Items.GetItemNamed('Country').value := GetField(fieldcountry);
eMovie.Items.Add('Length');
eMovie.Items.GetItemNamed('Length').value := GetField(fieldLength);
eMovie.Items.Add('Plot');
eMovie.Items.GetItemNamed('Plot').value :=GetField(fieldDescription);
eMovie.Items.Add('URL');
eMovie.Items.GetItemNamed('URL').value := GetField(fieldurl);
eMovie.Items.Add('Director');
eMovie.Items.GetItemNamed('Director').value := GetField(fielddirector);
eMovie.Items.Add('Rating');
eMovie.Items.GetItemNamed('Rating').value := GetField(fieldrating);
eMovie.Items.Add('Notes');
eMovie.Items.GetItemNamed('Notes').value := GetField(fieldcomments);
eMovie.Items.Add('Position');
eMovie.Items.GetItemNamed('Position').value := GetcustomField('pfad');
exportpicture(savepath + '12temp34\' + GetField(fieldnumber)+PictureExt);
eMovie.Items.Add('Cover');
eMovie.Items.GetItemNamed('Cover').value := GetField(fieldnumber)+PictureExt;
eMovie.Items.Add('Actors');
actorsvalue:=actorstoxml(getfield(fieldactors));
delete(actorsvalue,1,2)
eMovie.Items.GetItemNamed('Actors').value := actorsvalue;
eMovie.Items.Add('Loaned');
eMovie.Items.GetItemNamed('Loaned').value := GetField(fieldBorrower);
//eMovie.Items.Add('LoanedDate');
//eMovie.Items.GetItemNamed('LoanedDate').value := GetField();
//eMovie.Items.Add('PersonalRating');
//eMovie.Items.GetItemNamed('PersonalRating').value := GetcustomField('Prating');
eMovie.Items.Add('PurchaseDate');
eMovie.Items.GetItemNamed('PurchaseDate').value := GetField(fieldDate);
eMovie.Items.Add('Seen');
eMovie.Items.GetItemNamed('Seen').value := GetcustomField('gesehen');
end;
begin
if GetIteration = 0 then // First iteration
begin // We prepare XML
batch:=tstringlist.create;
batch.text:='mkdir ' + savepath + '12temp34';
batch.savetofile(dirapp + 'start.bat');
Launch(dirapp + 'start.bat','');
xml := TJvSimpleXml.create(nil);
xml.Root.Name := 'XMM_Movie_Database';
end;
// We add movie data
AddMovieData;
if GetIteration = GetIterationCount - 1 then // Last iteration
begin // We save XML to file and we close it
convert:=xml.savetostring;
convert:=stringreplace(convert,'iso-8859-1','utf-8');
convert:=utf8encode(convert);
//showmessage(convert);
exportxml:=tstringlist.create;
exportxml.text:=convert;
exportxml.savetofile(savepath+'12temp34\export.xml');
//xml.loadfromstring(convert);
//xml.SaveToFile(savepath)
//Launch();
batch.text:=dirapp+'7za.exe a ' + savepath + 'movies.zip ' + savepath + '12temp34\*' + #13#10 + 'rmdir /S /Q ' + savepath + '12temp34';
batch.savetofile(dirapp + 'start.bat');
Launch(dirapp + 'start.bat','');
xml.Free;
exportxml.free;
batch.free;
showmessage('FINISHED!');
end;
end.
now i have a other question because now i create a custom html template for me i have a problem
now it look like
Code: Select all
<html><head>
<style TYPE="text/css">
body { margin: 0em; padding: 0em; }
text,p,div,span,th,td,ul,li { FONT-SIZE: 10pt; FONT-FAMILY: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: black; background: white; }
div.header { font-size: 18pt; font-weight: bold; text-align: center; color: white; background: black;padding: 5px}
div.header2 { font-size: 10pt; font-weight: bold; text-align: center; color: yellow; background: black;padding: 5px; margin-bottom : 5px}
div.footer { font-size: 18pt; font-weight: bold; text-align: center; color: white; background: white; padding: 0px; margin-top : 5px}
hr { border: solid; border: 0; background-color: #000; color: #000; height: 3px; }
A:link { COLOR: #003399; background: white; }
A:visited { COLOR: #003399; background: white; }
A:hover { COLOR: #CC0000; background: white; }
A:active { COLOR: #CC0000; background: white; }
tr { vertical-align: top; padding : 0px; }
td.wh, table.wh { color: black; background: white; border: solid; border-color: white; vertical-align: middle; }
td.gr { color: black; background: #F5F5F5; border: solid; border-color: white; vertical-align: top; }
td.blk { color: white; background: black; border: solid; border-color: black; vertical-align: middle; }
table { color: black; background: white; border: none; }
</style></head><body>
<div class="header">$$ITEM_TRANSLATEDTITLE ($$ITEM_YEAR)</div>
<div class="header2">"$$ITEM_CF_TAGLINE"</div>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td class="wh" width="200"><img src="$$ITEM_PICTUREFILENAME" alt="poster" width="200" /></td>
<td>
<table border="0" cellspacing="0" cellpadding="1" width="100%">
<tr>
<td class="gr">$$LABEL_ORIGINALTITLE:</td>
<td class="wh">$$ITEM_ORIGINALTITLE</td>
</tr>
<tr>
<td class="gr" width="165">Gesehen/Nicht Gesehen:</td>
<td class="wh">$$ITEM_CF_GESEHEN</td>
</tr>
<tr>
<td class="gr" width="150">$$LABEL_RATING:</td>
<td class="wh">$$ITEM_APPR10 ($$ITEM_RATING) from $$ITEM_CF_VOTES Users</td>
</tr>
<tr>
<td class="gr">$$LABEL_COUNTRY:</td>
<td class="wh">$$ITEM_COUNTRY</td>
</tr>
<tr>
<td class="gr">FSK:</td>
<td class="wh">$$ITEM_CF_FSK</td>
</tr>
<tr>
<td class="gr">$$LABEL_LENGTH:</td>
<td class="wh">$$ITEM_LENGTHmin</td>
</tr>
<tr>
<td class="gr">$$LABEL_CATEGORY:</td>
<td class="wh">$$ITEM_CATEGORY</td>
</tr>
<tr>
<td class="gr">$$LABEL_DIRECTOR:</td>
<td class="wh">$$ITEM_DIRECTOR</td>
</tr>
<tr>
<td class="gr">$$LABEL_PRODUCER:</td>
<td class="wh">$$ITEM_PRODUCER</td>
</tr>
<tr>
<td class="gr">Studio:</td>
<td class="wh">$$ITEM_CF_STUDIO</td>
</tr>
<tr>
<td class="gr">Writer:</td>
<td class="wh">$$ITEM_CF_WRITER</td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="1" width="100%">
<!--<tr>
<td class="gr" width="150">$$LABEL_ACTORS:</td>
<td class="wh">$$ITEM_ACTORS</td>
</tr>-->
<tr>
<td class="gr">$$LABEL_DESCRIPTION:</td>
<td class="wh">$$ITEM_DESCRIPTION</td>
</tr>
<tr>
<td class="gr">$$LABEL_COMMENTS:</td>
<td class="wh">$$ITEM_COMMENTS</td>
</tr>
<tr>
<td class="gr" width="150">$$LABEL_URL:</td>
<td class="wh"><a href="$$ITEM_URL">$$ITEM_URL</a></td>
</tr>
<tr>
<td class="gr" width="150">Pfad:</td>
<td class="wh"><a href="$$ITEM_CF_PFAD">$$ITEM_CF_PFAD</a></td>
</tr>
</table>
<div class="footer"></div>
</body></html>
but i have a problem with the actors (that why there are deactivied)
my actor field has the folling value:
Code: Select all
Sean Penn (Paul Rivers | http://ia.media-imdb.com/images/M/MV5BMTc1NjMzMjY3NF5BMl5BanBnXkFtZTcwMzkxNjQzMg@@._V1._SY314_SX214_.jpg | http://akas.imdb.com/name/nm0000576/), Naomi Watts (Cristina Peck | http://ia.media-imdb.com/images/M/MV5BMTMyODUxOTk0MF5BMl5BanBnXkFtZTcwNjE0NDc2Mw@@._V1._SY314_SX214_.jpg | http://akas.imdb.com/name/nm0915208/), Danny Huston (Michael | http://ia.media-imdb.com/images/M/MV5BMTc0MDQyMjM2OV5BMl5BanBnXkFtZTcwNjc2NzMzMw@@._V1._SY314_SX214_.jpg | http://akas.imdb.com/name/nm0396812/), Carly Nahon (Cathy | | http://akas.imdb.comhttp://pro.imdb.com/widget/resume_redirect/), Claire Pakis (Laura | | http://akas.imdb.comhttp://pro.imdb.com/widget/resume_redirect/), Benicio Del Toro (Jack Jordan | http://ia.media-imdb.com/images/M/MV5BMTkzODQ4NzU1N15BMl5BanBnXkFtZTcwOTUzMzc5Mg@@._V1._SY314_SX214_.jpg | http://akas.imdb.com/name/nm0001125/), Nick Nichols (Boy | | http://akas.imdb.comhttp://pro.imdb.com/widget/resume_redirect/), Charlotte Gainsbourg (Mary Rivers | http://ia.media-imdb.com/images/M/MV5BNDQyMzQ5NTEzNl5BMl5BanBnXkFtZTcwNjI3NTEzNQ@@._V1._SY314_SX214_.jpg | http://akas.imdb.com/name/nm0001250/), John Rubinstein (Gynecologist | http://ia.media-imdb.com/images/M/MV5BMTcxNjM1OTk4MV5BMl5BanBnXkFtZTcwNjI1NjA2Mw@@._V1._SY314_SX214_.jpg | http://akas.imdb.com/name/nm0748270/), Eddie Marsan (Reverend John | http://ia.media-imdb.com/images/M/MV5BMjIzNjk0MTAxNV5BMl5BanBnXkFtZTcwMTA2NjQ0Mw@@._V1._SY314_SX214_.jpg | http://akas.imdb.com/name/nm0550371/), Loyd Keith Salter (Fat Man | | http://akas.imdb.comhttp://pro.imdb.com/widget/resume_redirect/), Antef A. Harris (Basketball Guy | | http://akas.imdb.comhttp://pro.imdb.com/widget/resume_redirect/)
actorname (role | actorpic | actorpage)
and now i want that in the html file it look like
actorname (with link to the page) ... role
Sean Penn ... Paul Rivers
Naomi Watts ... Cristina Peck
and so on
how can i do that
sry that i asked so many questions^^
Posted: 2012-07-19 08:43:05
by antp
You won't be able to generate links automatically using the HTML export.
Only solution would be to include Javascript in the page that will convert links when the page is loaded in a web browser.
Posted: 2012-07-19 08:56:29
by I-Catch
i don't want to export i mean the html in the program itself
http://mickaelvanneufville.online.fr/AM ... pture1.png
Posted: 2012-07-19 09:13:00
by soulsnake
Hi,
Another solution is to create a custom field (e.g. ACTORS_HTML) of type TEXT and you fill it using a script that format field ACTORS like you want for html export/display.
This way you can use custom field (e.g. ACTORS_HTML) in your template with actors formatted like you want !
Soulsnake.
Posted: 2012-08-18 20:41:07
by vunvun
hi,
I'm new here. Can you please explain how to run the script to export the movie data to Movielicious for android. Thanks in advance.
Posted: 2012-10-13 04:02:38
by sweborn
Good question.. I also want to know how to export to an Movielicious zip file.
Edit: NO RESPONS!
Posted: 2014-03-04 15:41:14
by jandes
Hi,
sorry for my bad english
I modified the code write by I-catch and work fine,
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=
Title=Movielicious export
Description=Exports Movies to Movielicious XML format
Site=
Language=?
Version=
Requires=4.1.1
Comments=
License=
GetInfo=1
[Options]
***************************************************)
program MovieliciousExport;
uses
SoulSnakeUtils ;
var
xml: TJvSimpleXml;
exportxml,batch:tstringlist;
convert,actorsvalue:string;
const
savepath = 'C:\Users\jan\Desktop\catalog\';
//savepath = 'Z:\media\Daten_2TB\movies\';
//savepath = 'C:\Users\snake\Desktop\MovieliciousExport.xml';
function ActorsToXml(actors: string): string;
var
lstActor: TStringList;
iActor,startpos: Integer;
sActor,name: string;
begin
lstActor := TStringList.Create;
lstActor.Text := stringreplace(actors,', ',#13#10);
for iActor := 0 to lstActor.Count - iActor do
begin
startpos:= pos(' (',lstActor.GetString(iActor));
name:=copy(lstActor.GetString(iActor),0,startpos-1);
sActor := ', ' + name ;
if lstActor.GetString(iActor) <> #13#10 then lstActor.SetString(iActor, sActor);
end;
Result := lstActor.Text;
lstActor.Free;
end;
procedure AddMovieData;
var
eMovie: TJvSimpleXmlElem;
seen:string;
begin
xml.Root.Items.Add('Movie');
eMovie := xml.Root.Items.GetItemNamed('Movie');
eMovie.Items.Add('MovieID');
eMovie.Items.GetItemNamed('MovieID').value := GetField(fieldnumber);
// eMovie.Items.Add('CatalogNr');
// eMovie.Items.GetItemNamed('CatalogNr').value := GetField(fieldnumber);
eMovie.Items.Add('Title');
eMovie.Items.GetItemNamed('Title').value := GetField(fieldtranslatedtitle);
eMovie.Items.Add('Media');
eMovie.Items.GetItemNamed('Media').value := GetField(fieldMediaType);
eMovie.Items.Add('Genre');
eMovie.Items.GetItemNamed('Genre').value := GetField(fieldCategory);
eMovie.Items.Add('Year');
eMovie.Items.GetItemNamed('Year').value := GetField(fieldyear);
eMovie.Items.Add('MPAA');
eMovie.Items.GetItemNamed('MPAA').value := GetCustomField('fsk');
eMovie.Items.Add('Country');
eMovie.Items.GetItemNamed('Country').value := GetField(fieldcountry);
eMovie.Items.Add('Length');
eMovie.Items.GetItemNamed('Length').value := GetField(fieldLength);
eMovie.Items.Add('Plot');
eMovie.Items.GetItemNamed('Plot').value :=GetField(fieldDescription);
eMovie.Items.Add('URL');
eMovie.Items.GetItemNamed('URL').value := GetField(fieldurl);
eMovie.Items.Add('Director');
eMovie.Items.GetItemNamed('Director').value := GetField(fielddirector);
eMovie.Items.Add('Rating');
eMovie.Items.GetItemNamed('Rating').value := GetField(fieldrating);
// eMovie.Items.Add('Notes');
// eMovie.Items.GetItemNamed('Notes').value := GetField(fieldcomments);
eMovie.Items.Add('Position');
eMovie.Items.GetItemNamed('Position').value := GetField(fieldMedia);
exportpicture(savepath + '12temp34\' + GetField(fieldnumber)+PictureExt);
eMovie.Items.Add('Cover');
eMovie.Items.GetItemNamed('Cover').value := GetField(fieldnumber)+PictureExt;
eMovie.Items.Add('Actors');
actorsvalue:=actorstoxml(getfield(fieldactors));
delete(actorsvalue,1,2)
eMovie.Items.GetItemNamed('Actors').value := actorsvalue;
eMovie.Items.Add('Loaned');
eMovie.Items.GetItemNamed('Loaned').value := GetField(fieldBorrower);
//eMovie.Items.Add('LoanedDate');
//eMovie.Items.GetItemNamed('LoanedDate').value := GetField();
eMovie.Items.Add('PurchaseDate');
eMovie.Items.GetItemNamed('PurchaseDate').value := GetField(fieldDate);
eMovie.Items.Add('Seen');
eMovie.Items.GetItemNamed('Seen').value := GetcustomField('Visto');
end;
begin
if GetIteration = 0 then // First iteration
begin // We prepare XML
batch:=tstringlist.create;
batch.text:='mkdir ' + savepath + '12temp34';
batch.savetofile(dirapp + 'start.bat');
Launch(dirapp + 'start.bat','');
xml := TJvSimpleXml.create(nil);
xml.Root.Name := 'XMM_Movie_Database';
end;
// We add movie data
AddMovieData;
if GetIteration = GetIterationCount - 1 then // Last iteration
begin // We save XML to file and we close it
convert:=xml.savetostring;
convert:=stringreplace(convert,'iso-8859-1','utf-8');
convert:=utf8encode(convert);
//showmessage(convert);
exportxml:=tstringlist.create;
exportxml.text:=convert;
exportxml.savetofile(savepath+'12temp34\export.xml');
//xml.loadfromstring(convert);
//xml.SaveToFile(savepath)
//Launch();
// batch.text:=dirapp+'7za.exe a ' + savepath + 'movies.zip ' + savepath + '12temp34\*' + #13#10 + 'rmdir /S /Q ' + savepath + '12temp34';
// batch.savetofile(dirapp + 'start.bat');
// Launch(dirapp + 'start.bat','');
xml.Free;
exportxml.free;
batch.free;
showmessage('FINISHED!');
end;
end.
but there is an error in the original code; the function ActorsToXml not work and return only commas
Thanks