XML or HTML? The Javascript document represents the HTML DOM document. Of course you can generate some HTML as XML document.
I have no idea how this question is related to "setting a counter" or your code, but "update XML" simply means creating some string with XML content based on some existing XML content. If you have some XML text, you parse the whole thing, do some modifications and generate the whole content as a new string.
If you want to work with HTML DOM (I still cannot be sure), it is already parsed since loaded. If you need to parse some XML from scratch, there is a jQuery parser:
https://api.jquery.com/jQuery.parseXML[
^].
On generation of XML, please see:
http://oreilly.com/pub/h/2127[
^],
http://stackoverflow.com/questions/7152064/how-to-create-xml-file-with-jquery[
^],
http://stackoverflow.com/questions/3191179/generate-xml-document-in-memory-with-javascript[
^].
—SA