StringBuffer xpathBuffer = new StringBuffer();
xpathBuffer.append("//").
append(MCSNamespace.DEVICE_IDENTIFICATION.getPrefix()).
append(':').
append(DeviceRepositorySchemaConstants.DEVICE_ELEMENT_NAME);
XPath xpath = new XPath(xpathBuffer.toString(),
new Namespace[]{MCSNamespace.DEVICE_IDENTIFICATION});
List matches = new ArrayList();
try {
// Apply the XPath expression to the root of the document provided
List nodes = xpath.selectNodes(root);
if (nodes != null) {
// Iterate over the devices selected by the XPath. For each
// device check its patterns agains the regular expression. If
// there is a match then add the device to the list of matches.