开发者

How can I escape a string in classic ASP for use in XPath query?

开发者 https://www.devze.com 2022-12-18 10:32 出处:网络
I have string I\'d like to escape for use in an XPath query.In C# I am able to do this using a call to SecurityElement.Escape.Is there an equivalent call开发者_如何学Python in classic ASP?No, you\'ll

I have string I'd like to escape for use in an XPath query. In C# I am able to do this using a call to SecurityElement.Escape. Is there an equivalent call开发者_如何学Python in classic ASP?


No, you'll need to deal with string escape yourself.

xpath = "//node[@attribute='" & SecurityElementEscape(value) & "']"

Function SecurityElementEscape(value)
    SecurityElementEscape = 
        Replace(Replace(Replace(Replace(Replace(value, 
            "&" , "&" ), '' // must be first one
            "<" , "&lt;"  ),
            ">" , "&gt;"  ), 
            """", "&quot;"), 
            "'" , "&apos;") 
End Function
0

精彩评论

暂无评论...
验证码 换一张
取 消