Well, that kind of depends. If it's straight-up XML, use xml.attribute('whatever') on an XML object, which "Returns a list containing all attribute elements matching the given name." If it's XML that has been imported into InDesign, try something along the lines of app.activeDocument.xmlElements.item(0).xmlAttributes.item('type').value to get the value of an attribute, and just loop through each element (replacing 0 with the loop index, of course).
You can also give this library a try : xmljs.
It may ease your process.
You may also get quicker result working with the xml file itself rather than going through the xml structure within Indesign which may be slow to proceed.
If the xml has been linked you can get the file back in the links panel. If it wasn't, you may export the xml and proceed with this exported file.
Hope it helps.
Finally, if you grab the xml content as text, you may also proceed with regexp, but I did'nt verify it it was a quick
er way to go or not.
I would use xpath. Read the xml data into an xml object:
var myXML = new XML(<tags><tag type="a"><mydata>Adobe</mydata></tag><tag type="b"><mydata>InDesign</mydata></tag><tag type="c"><mydata>Adobe InDesign</mydata></tag></tags>);
This expression will return every tag element with a type attribute with value "a":
var typeATags = myXML.xpath("//tag[@type='a']");