const parser = new DOMParser();
const xmlSource = '<svg xmlns="http://www.w3.org/2000/svg"></svg>';
const svgDocument2 = parser.parseFromString(xmlSource, 'application/xml');
console.log(
'count(//svg)',
svgDocument.evaluate('count(//svg)', svgDocument2, null, XPathResult.NUMBER_TYPE).numberValue
);
svgDocument.evaluate('count(//svg:svg)', svgDocument2, namespaceResolver, XPathResult.NUMBER_TYPE).numberValue
const namespaceMap = {
svg: 'http://www.w3.org/2000/svg',
xlink: 'http://www.w3.org/1999/xlink'
};
const namespaceResolver = prefix => namespaceMap[prefix || ''] || null;