I have some javascript which is loading an XML document and filtering the elements based on a particular attribute.
The XML structure is similar to the structure below:
<locations> <region name="metro" title="Metropolitan"> <location type="HQ"> <name>Head Office</name> </location> <location type="NM"> <name>North Metro</name> </location> </region> <region name="south" title="Southern region"> <location type="SR"> <name>South Regional Office</name> </location> </region> </locations>
The javascript is extracting the elements for a specified region, the relevent lines of code are as follows:
// supplied region name in this case is "metro"var _xpath = "/locations/region[@name="" + regionName + ""]";var _regionList;// code for IE .... not shown// code for other browsers_regionList = mLocationsXmlDoc.evaluate(_xpath, mLocationsXmlDoc, null, XPathResult.ANY_TYPE, null);
Now this works perfectly well in Firefox, Chrome and Opera… but does not work in Safari.
When executing in Safari, the _regionList variable ends up as null with an error message "TYPE_ERR: DOM XPath Exception 52: The expression could not be converted to return the specified type" thrown and I can't figure out why. Any help and suggestions would be appreciated