I'm parsing an XML string (VMAP to be exact) using DOMParser() and trying to iterate over the children using XPath, and I'm getting a very unhelpful error IKDOMXPathException with code 52. The code works fine in desktop Safari, Chrome or Firefox, but fails under TvOS/TVJS.
First question, is how do I know what type of error that is? I've seen various types of IKBlahException's all with error codes, but no actual messages. Searching through the documentation doesnt seem to explain how I can use this.
Most importantly though, how can I get this to work? A reduced test case that works in all environments except TVOS
try {
var vmap = `
<vmap:VMAP version="1.0" xmlns:uo="uo" xmlns:vmap="http://www.iab.net/vmap-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<vmap:AdBreak breakType="linear" breakId="PreRoll_0_0" timeOffset="start">
<vmap:AdSource allowMultipleAds="true" followRedirects="true" id="0"></vmap:AdSource>
</vmap:AdBreak>
<vmap:AdBreak breakType="linear" breakId="MidRoll_408_0" timeOffset="00:06:48.000">
<vmap:AdSource allowMultipleAds="true" followRedirects="true" id="1"></vmap:AdSource>
</vmap:AdBreak>
</vmap:VMAP>
`;
var namespaces = {uo: 'uo', vmap: 'http://www.iab.net/vmap-1.0', xsi: 'http://www.w3.org/2001/XMLSchema-instance'}
var parser = new DOMParser();
var vmap = parser.parseFromString(vmap, 'application/xml');
var xpathResults = vmap.evaluate('//vmap:AdBreak', vmap, function(prefix) {
return namespaces[prefix]
})
var result = xpathResults.iterateNext()
while (result) {
console.log(result);
result = xpathResults.iterateNext();
}
} catch (err) {
console.log('Error');
console.log(err);
console.log(err.code);
}