update the data of treeGrid

What the function I want to achieve is:
when I click a button, I hope produce a xml files,just like
<items><item><accountCode>xxx</accountCode><accountName>xxx</accountName></item></items>
xxx is the data in the treeGrid.
And I just want get the data which it’s checked is true.
But I do not know where and how to foreach every row of treeGrid,
and I do not know how to get the checked status of it.

These are my problem

The below is the code of treeGrid:
isc.TreeGrid.create({
ID:“tGridAccountCode”,
dataSource:“accountCodeDS”,
selectionAppearance:“checkbox”,
cascadeSelection:true,
dataProperties:{
loadDataOnDemand:false,
dataArrived:function (parentNode) {
this.openAll();
}
},
fields:[
{name:“accountCode”, treeField:true},
{name:“accountName”}
], autoDraw:false,
width:“400”,
height:“50%”,
top:“50%”
});

Have you looked at TG.getSelection()?

I try it now.
Thanks a lot.

Dear davidj6:
Thank you for your answer.
I have another problem now.
I can get all the checked rows by using tg.getSelection(), but how can I get the rows which is just the root node?

Do you mean tg.data.getRootNode()?

What I mean is that get the root node selected