如何选择节点的名字? XPath [英] How to select a node's first child name? XPath

查看:74
本文介绍了如何选择节点的名字? XPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XML,必须从中选择一个节点的孩子的名字。我是一个初学者,所以没有找到Xpath表达式来实现。我知道节点的级别

I have an XML from which I have to select the name of the child of one of the nodes. I'm kind of a beginner in this, so I didn't find the Xpath expression to do it. I know the level of the node

示例

<$ c中的名称$ c> / Employee / Department /

但是Department的子节点名称未知。我必须选择Department节点的第一个孩子。我该怎么办?

but Department has children nodes of unknown names. I have to select the first child of Department node. How can I do this?

推荐答案

您写道:


我必须选择
Department节点的第一个孩子

I have to select the first child of Department node

您可以使用:

/Employee/Department/*[1]

然后,您还写道:


我有一个XML,必须从中获取
选择
个节点之一的子节点的名称

I have an XML from which I have to select the name of the child of one of the nodes

因此,您可以使用:

name(/Employee/Department/*[1])

这篇关于如何选择节点的名字? XPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆