Recently, I came across an error with facebook XML feed file where I am getting an error that “Facebook XML file too long“.
After doing some research, I found that Facebook recently changed its policy for the XML file for Facebook product catalog.
Here is a detailed error message, “your XML data feed file is too long and exceeds our size limit of 5,242,880 bytes (5 MB) or characters”.
If you are facing the same problem then, please check your XML content is in a single line when you open it in notepad. See below image
Solution
This error occurs due to, XML document doesn’t use indent when generating XML file.
Since I mainly work with .NET and C# language, I resolved this issue by adding the following code for the XML Settings parameter. Its sample code only to resolve the error
var settings = new XmlWriterSettings { Encoding = Encoding.UTF8, Indent = true };
XmlWriter writer = XmlWriter.Create("file_Name.xml", settings);
writer.WriteStartDocument();
writer.WriteStartElement("rss");
writer.WriteStartElement("item");
writer.WriteElementString("g", "id", googleBaseNamespace, "1" );
writer.WriteStartElement("title");
writer.WriteCData("Jeans");
writer.WriteEndElement(); // title
writer.WriteEndElement(); // item
writer.WriteEndElement(); // rss
writer.WriteEndDocument();
writer.Flush();
writer.Close();
After this modification even if you open a file in notepad, you will see single property only in each line. Refer below image
This feed file is now accepted by Facebook. One more important thing is, the file size will increase a little bit.