I am not sure what the problem is. Could you tryrunning the code again after prefixing your xml stringwith this string:<?xml version="1.0"?>When using file based xml, this declaration has to bethe first line in my file. Hope it works for you.