英文:
How to write the Xpath for the json field having white space?
问题
我想为一个包含空格的 JSON 字段编写 XPath 表达式。
[
{"name":"Ram", "email id":"ram@gmail.com", "age":23},
{"name":"Shyam", "email id":"shyam23@gmail.com", "age":28}
]
我尝试使用以下方式获取 email id:
?1?email id
当我在开源项目中搜索时,我了解到在 XPath 3.1 中是不可能的。XPath 4.0 支持上述方式:
?1?'email id'
有人可以帮助我如何使用 XPath 4.0 吗?是否需要添加任何依赖项?
英文:
I want to write the xpath for a json field which is having white spaces in it.
[
{"name":"Ram", "emai ld":"ram@gmail.com", "age":23},
{"name":"Shyam", "email id":"shyam23@gmail.com", "age":28}
]
I tried as below to get the email id:
?1?email id
When I searched in open source I got to know this is not possible in Xpath 3.1. Xpath 4.0 supports the above as
?1?'email id'
Can somebody helps how I can use Xpath 4.0? Meaning any dependency that I need to add?
答案1
得分: 1
你需要将字符串字面值放在括号中:
?1?('电子邮件ID')
英文:
You need to put the string literal in parentheses:
?1?('email id')
答案2
得分: 1
或者只需使用?1('email id')
调用地图。
英文:
Or just call the map with e.g. ?1('email id')
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论