I am building a game in cocos2dx and I am saving game data in CCUserDefault. Now I have decided to save this data on any server. What I do is accessing XML file of CCUserDefault and convert it into JSON.

My app crashes doing so and the reason is some garbage values at the end of XML file as shown in the image. App works fine whenever garbage values doesn't appear.