Updated code for XML support