Scoped XMLNode - hasAttribute(String attribute)

Determines if the node has the specified attribute.

Table 1. Parameters
Name Type Description
attribute String The name of the attribute to check.
Table 2. Returns
Type Description
Boolean True if the node has the attribute.
var xmlString = "<test>" +
                "  <one>" +
                "    <two att=\"xxx\">abcd1234</two>" +
                "    <three boo=\"yah\" att=\"yyy\">1234abcd</three>" +
                "    <two>another</two>" +
                "  </one>" +
                "  <number>1234</number>" +
                "</test>";
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(xmlString);
var node = xmlDoc.getNode('//two');
gs.info(node.hasAttribute('att'));

Output: true