This project is read-only.

XML error in API

Feb 8, 2011 at 11:07 AM
Edited Feb 8, 2011 at 11:08 AM

Hi,

thanks for this API, but it seems broken for me. Starting the example project results in an XML error. Same problem in my own project:

 

System.InvalidOperationException: Fehler im XML-Dokument (8,8). ---> System.FormatException: Die Eingabezeichenfolge hat das falsche Format.
   bei System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   bei System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
   bei System.Xml.XmlConvert.ToDecimal(String s)
   bei Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderTmdbMovieSearchResults.Read11_TmdbMovie(Boolean isNullable, Boolean checkType)
   bei Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderTmdbMovieSearchResults.Read12_TmdbMovieSearchResults(Boolean isNullable, Boolean checkType)
   bei Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderTmdbMovieSearchResults.Read13_OpenSearchDescription()
   --- Ende der internen Ausnahmestapel�berwachung ---
   bei System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   bei System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)

Mar 8, 2011 at 1:34 PM

Hi,

when looking at the exception I can see that you use a german version of Visual Studio xx. The problem ist that the API has a globalization problem:

1. All variables of the type decimal can not be converted because they return as decimal seperator a period (".") instead of a comma (",").

2. You cannot get german text infos because always "en/xml" is used.

English only URL:
private const string MOVIE_SEARCH_URL = http://api.themoviedb.org/2.1/Movie.search/en/xml/{0}/{1}

International URL:
private const string MOVIE_SEARCH_URL = http://api.themoviedb.org/2.1/Movie.search/{2}/xml/{0}/{1}

where "{2}" is "de-DE" or "de" for german.

A different way to get the information from the XML response is to put then into Dataset which you can display in a DataGrid

public DataSet MovieSearch(string title)
{
WebClient webClient = new WebClient(); 
string Request = string.Format(MOVIE_SEARCH_URL, ApiKey, Escape(title), "de-DE");
byte[] data = webClient.DownloadData(Request); 
string xml = System.Text.Encoding.UTF8.GetString(data); 
if (!xml.StartsWith("<?xml"))
throw new Exception(xml.Replace("<p>", "").Replace("</p>", "" )); 
DataSet ds = new DataSet("Movies");
ds.ReadXml(
new StringReader(xml));
return ds;
}

 

Apr 1, 2011 at 8:31 PM

I must say, I feel it is a more fundamental flaw in the project.

Quite a lot of places in the code where a piece of information is thought as a number, the variable is defined as decimal or integer.

And since there apparently is no xml schema (afaik) for the results from tmdb, we WILL run onto trouble sooner or later.

My own philosophy on the subject is: If I don't expect to do any arithmetic on it, it is a STRING

 

Erik