added method to read xml from memory
fixed bugs