Here you can find the source of getBaseLocation(byte[] metadata)
public static String getBaseLocation(byte[] metadata)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Document; import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import java.io.ByteArrayInputStream; import java.io.IOException; public class Main { private static final XPath xPath = XPathFactory.newInstance().newXPath(); private static final String BASE_LOCATION = "/artifact/baselocation/text()"; public static String getBaseLocation(byte[] metadata) { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder;/* w w w. j a va 2 s . co m*/ try { builder = builderFactory.newDocumentBuilder(); Document document = builder.parse(new ByteArrayInputStream(metadata)); return (String) xPath.compile(BASE_LOCATION).evaluate(document, XPathConstants.STRING); } catch (XPathExpressionException | ParserConfigurationException | SAXException | IOException e) { return null; } } }