In the XML you posted, an <entries> element has seven children. There are three <entry> elements and four white-space text elements; you may not have been aware of the latter. It looks to me like your code tries to add the new <entry> element as a child of the last of those seven elements, which is whitespace text. Text elements can't have children.
You need to add the new <entry> element as a new child of the <entries> element. You might also want to add another whitespace text element to make the resulting XML look nice, but don't do that until you are told to do so, as it doesn't change the meaning of the document.
The loop j may be better used by reversing order of the index and coupled it with "break" for the first match. But this is only a detail you have to consider rewriting everywhere.
 The main error asked. It is an misunderstanding of appendChild(). Line #48
 On the whole, the code does not give enough credit to java's DOM model. If you use DOM to flatten the xml tree using getChildNodes(), it is far away to use the more pertinent method getElementsByTagName() on the child Element everywhere. For instance, line #35
The coding inside would have to be rewritten. It would be greatly simplified and more focused.., eliminating a lot of checking...