This project is read-only.



{"There is an error in XML document (22, 8)."}
Inner Exception
{"Input string was not in a correct format."}

file attachments

Closed Dec 7, 2011 at 4:54 PM by darick_c


enooijen wrote Nov 14, 2010 at 11:15 AM

I had the same issue. In my case it was caused by movies without a score (returned value "<score></score>").
This can be fixed by an update to the Score attribute of a movie:
    public string ScoreElement
            if (Score == null) 
                return String.Empty; 
                return Score.ToString(); 
            if (value == null || value.Length == 0)
                Score = null;
                Score = Convert.ToDecimal(value);

    public decimal? Score{ get; set; }

wrote Dec 1, 2010 at 6:08 PM

wrote Dec 2, 2010 at 8:48 AM

wrote Jan 2, 2011 at 12:48 AM

wrote Jan 12, 2011 at 12:24 AM

jonnyc wrote Jan 12, 2011 at 12:24 AM

I had this issue too and the way I solved it was to remove these empty elements before deserializing. With the help of this sample code (, I ended up with...
    public static T Deserialize<T>(string xml)
        XmlSerializer xs = new XmlSerializer(typeof(T));
        string cleanXml = xml;
        cleanXml = Regex.Replace(xml, @"<[a-zA-Z].[^(><.)]+/>", string.Empty);
        cleanXml = Regex.Replace(xml, @"<([a-zA-Z].[^(><.)]+)></\1>", string.Empty);
        MemoryStream memoryStream = new MemoryStream((new UTF8Encoding()).GetBytes(cleanXml));
        XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
        return (T)xs.Deserialize(memoryStream);
    public TmdbMovie[] MovieSearch(string title)
TmdbMovieSearchResults search = XmlUtility.Deserialize<TmdbMovieSearchResults>(xml);
This seems to be the best way in my opinion since you never know which elements are going to be empty and it will keep your serialization classes untouched.

I've attached a diff file for the complete changes, although I've only modified the MovieSearch method in the diff to use the new method.

darick_c wrote Oct 19, 2011 at 5:09 AM

I have re-written the code to use json instead of xml, hopefully that will help. Also, I have changed some of the property types.

wrote Dec 7, 2011 at 4:54 PM

wrote Feb 14, 2013 at 3:05 AM

wrote May 16, 2013 at 8:43 AM