zoukankan      html  css  js  c++  java
  • xpath中的转义字符

    xpath中只转义单引号和双引号两个字符

    //you may want to use constants like HtmlTextWriter.SingleQuoteChar and
    //HtmlTextWriter.DoubleQuoteChar intead of strings like "'" and "\""
    private static string GenerateConcatForXPath(string a_xPathQueryString)
    {
        string returnString = string.Empty;
        string searchString = a_xPathQueryString;
        char[] quoteChars = new char[] { '\'', '"' };
     
        int quotePos = searchString.IndexOfAny(quoteChars);
        if (quotePos == -1)
        {
            returnString = "'" + searchString + "'";
        }
        else
        {
            returnString = "concat(";
            while (quotePos != -1)
            {
                string subString = searchString.Substring(0, quotePos);
                returnString += "'" + subString + "', ";
                if (searchString.Substring(quotePos, 1) == "'")
                {
                    returnString += "\"'\", ";
                }
                else
                {
                    //must be a double quote
                    returnString += "'\"', ";
                }
                searchString = searchString.Substring(quotePos + 1,
                                 searchString.Length - quotePos - 1);
                quotePos = searchString.IndexOfAny(quoteChars);
            }
            returnString += "'" + searchString + "')";
        }
        return returnString;
    }

  • 相关阅读:
    hdu 2089 不要62(数位dp)
    hdu 3555 Bomb(数位dp)
    hdu 4544 湫湫系列故事——消灭兔子(优先队列)
    STL Algorithms 之 unique
    hdu 1075 What Are You Talking About(map)
    hdu 4268 Alice and Bob(贪心+multiset)
    hdu 4302 Holedox Eating(优先队列/线段树)
    9-16Jenkins-4节点
    9-16Jenkins-3可用的环境变量、参数化构建和依赖
    9-16Jenkins-2定时任务
  • 原文地址:https://www.cnblogs.com/liyulong1982/p/2765854.html
Copyright © 2011-2022 走看看