If you are trying to parse an xml file something like this could help you out:
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(file);
XPath xPath = XPathFactory.newInstance().newXPath();
String expression = "//pqr/@ref1"; // This line defines the element or attribute that you want to retrieve
Node node = (Node) xPath.compile(expression).evaluate(doc, XPathConstants.NODE);
String nodeValue = node.getTextContent();
If your xml file has repeating elements and attributes you might want to store your values in a NodeList. For that you could use:
NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET);
You should check out these links:
http://www.roseindia.net/tutorials/xPath/index.shtml
https://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx