public static List<String[]> getNamespaces(String xml)
            throws XMLStreamException, FactoryConfigurationError{
        List<String[]> res= new ArrayList<>();
        XMLStreamReader reader;
        if(StringUtils.isNotEmpty(xml)) {
            reader = XMLInputFactory.newFactory().createXMLStreamReader(new StringReader(xml));
            while (reader.hasNext()) {
                int event = reader.next();
                if (XMLStreamConstants.START_ELEMENT == event ||
                        XMLStreamConstants.NAMESPACE == event) {
                    addToList(reader, res);
                }
            }
        }
        return res;
    }
@Test
    public void testGetNamespaces() throws XMLStreamException, FactoryConfigurationError {
        String responseData = "<age:ag xmlns:age=\"http://www.w3.org/wgs84_pos#\">\n"
                + "<hd:head xmlns:hd=\"http://www.w3.org/wgs85_pos#\"><title>test</title></hd:head></age:ag>";
        List<String[]> res = XPathUtil.getNamespaces(responseData);
        assertEquals("age", res.get(0)[0]);
        assertEquals("http://www.w3.org/wgs84_pos#", res.get(0)[1]);
        assertEquals("hd", res.get(1)[0]);
        assertEquals("http://www.w3.org/wgs85_pos#", res.get(1)[1]);
    }