从Hive/Spark中选择XML的值
我有XML:
<info>
<infofield name "date">2022-01-01</infofield>
<infofield name "country">USA</infofield>
<infofield name "city">New York</infofield>
</info>
我想在XPATH上选择“纽约”,但是当我编写此查询时: 选择XPATH_STRING(正文,'info/infofield [3]/@name')我的结果是 - “城市”,我如何选择“纽约”?
I have xml:
<info>
<infofield name "date">2022-01-01</infofield>
<infofield name "country">USA</infofield>
<infofield name "city">New York</infofield>
</info>
I want select "New York" with xpath, but when i am write this query:
Select xpath_string(body,'info/infofield[3]/@name') my result is - "city", how i can select "New York"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的方法:
如果您想成为岸上,如果Infofield的顺序发生了变化,那么您仍然会得到TE City,这是更好的方法:
The easy way:
If you want to be shore that if the sequence of infofields changes, you still get te city this is the better way: