在iOS中评估基于XPath函数的表达式

时间:2012-08-08 21:25:44

标签: ios xml function xpath expression

有没有办法在iOS中评估xPath表达式?例如,表达式如下:

concat(xyz:field3, "!")

编辑:我只关注基于函数的xPath表达式(例如concat,substring,abs)

我尝试使用 stringByEvaluatingJavaScriptFromString 来运行以下脚本,该脚本将xPath表达式和XML文件作为输入,但我没有得到任何输出。

    function evaluateXPath(inputXML,xPathExpr)
    {
        // load the XML document

        xmldoc=loadXMLDoc(inputXML);

        // process the input doc

        xPathResult = xmldoc.evaluate(xPathExpr, xmldoc, null, XPathResult.ANY_TYPE, null);

        // convert result to string and return the string

        var serializer = new XMLSerializer();
        try {                        
            var str = serializer.serializeToString(xPathResult);                        
            // alert ("OUTPUT: "+str);                        
            return str; 
        }                    
        catch (e) {   
            // error catching stuff
        }  

    }               

0 个答案:

没有答案