具有以下XML:
<exceptions>
<exception name="LegacyException" msg="ERREUR DU MODULE SERVEUR">
<context name="default" msg="ERREUR DU MODULE SERVEUR (%1$s) : %2$s" />
</exception>
</exceptions>
如何通过XPath选择异常名称和上下文名称?
类似这样的东西:
String className = "LegacyException";
String contextName= "default";
String query = "//exception[@name='" + className + "' and context[@name='" + contextName+ "']]";
XPathExpression<Element> xpe = XPathFactory.instance().compile(query, Filters.element());
答案 0 :(得分:0)
此xpath表达式
//exceptions/exception/@name
or
//exception/@name
评估为
LegacyException
与此同时
//exceptions/exception/context/@name
or
//context/@name
评估为
default