You can easily do that by using the right statements in your search parameter for xml.selectSingleNode():
code:
var node = xml.selectSingleNode("badges[@category='soldier'][@level='1']/tasks[@id='1']");
var total = node.getAttribute("total");
The parts in
green are selectors for attributes, this means that the XMLDOM engine will first look for a node with the name 'badges' and then will check if it's category-attribute equals 'soldier' and the level is '1'. If this is true, it'll look in its child nodes for 'tasks'-nodes and if it finds one with id '1', it'll return that node. Then, you can simply use the Node.getAttribute("attribute_name") method to get the 'total' attribute from the node.