Use XML manipulation instead of string replacement