Added more error checking to xml parser

Xml parser is mostly safe, could use more error checking in preamble +
make more generic