小编ame*_*war的帖子

由于名称中存在撇号,无效的 XPath 表达式异常

我收到以下代码的无效 Xpath 异常。

current.Name = current.Name.replace("'", "\'");
System.out.println(current.Name );
String xp1 = "//page[@name='"+current.Name+"']" ;
Element n = (Element) oDocument.selectSingleNode(xp1+"/Body/contents");
Run Code Online (Sandbox Code Playgroud)

当 current.name 中的字符串中有撇号时会发生异常

current.name: "Répartition par secteur d'activité"

错误信息

java xml xpath

5
推荐指数
1
解决办法
8602
查看次数

标签 统计

java ×1

xml ×1

xpath ×1