Add ImageIndex to Treeview
The moment you start copy-pasting code and only changing one small thing, it's time to move that code to a method.

private void CreateAndAddNode(WhateverTypeImagesIndexIs imagesIndex, int x)
{
    var tNode2 = new TreeNode(xNode.Attributes["NAME"].Value, imagesIndex, imagesIndex);
    inTreeNode.Nodes.Add(tNode2);
    tNode2 = inTreeNode.Nodes[x];
    AddNode(xNode, tNode2);
}


I'm assuming AnalogImagesIndex etc. all inherit from some base type; that's the one to use as the method's parameter.



Moreover, all of those ifs can be changed to a switch.