XML generation and parsing