验证.NET中的XPath [英] Verify an XPath in .NET
本文介绍了验证.NET中的XPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何验证给定的xpath字符串在C#/.NET中有效?
How can I verify a given xpath string is valid in C#/.NET?
我不确定仅运行XPath并捕获异常是否是有效的解决方案(暂时将胆汁放在喉咙旁)-如果明天遇到其他未测试的输入怎么办?
I'm not sure just running the XPath and catching exceptions is a valid solution (putting aside the bile in my throat for a moment) - what if tomorrow I run into some other input I haven't tested against?
推荐答案
如何验证给定的XPath字符串在C#/.NET中有效?
How can I verify a given XPath string is valid in C#/.NET?
您尝试从中构建一个 XPathExpression
并捕获异常.
You try to build an XPathExpression
from it and catch the exception.
try
{
XPathExpression.Compile(xPathString);
}
catch (XPathException ex)
{
MessageBox.Show("XPath syntax error: " + ex.Message);
}
这篇关于验证.NET中的XPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文