I am working on typescript based node program and trying to read XML data from already existing xml file (this file is getting downloaded from third party location) . I use xpath in this scenario (https://www.npmjs.com/package/xpath)
Below is the root node of XML file
<bookstore xmlns="https://www.example.com/schema/papers/doc/5.0" id="5001" name ="amber" >
Below is the sample code
var somePath = //abc
var result = xpath.evaluate(
somePath, // xpathExpression
someDocument, // contextNode
{“”: “https://www.example.com/schema/papers/doc/5.0”},// namespaceResolver
xpath.XPathResult.ANY_TYPE, // resultType
null // result
);
However I couldn’t able to retrieve any data with above code. I found that this code doesn't resolve the name space.Reason seems that there is no valid namespace available to identify current namespace.
For example if third party XML have namespace such as xmlns:abc=https://www.example.com/schema/papers/doc/5.0 I can simply use it under xpath.eveluate (e.g. {“abc”: “https://www.example.com/schema/papers/doc/5.0”}) and retrieve required data.
Is there any way to retrieve data from this kind of namespaces with no name? Please be kind enough to shed some light on this. Thanks in advance.