使用XPath检索XML子元素名称

使用XPath检索XML子元素名称,xml,xpath,Xml,Xpath,我需要检索子元素名,而不是元素值。 我在下面附上了我的XML <TaskInfo> <Appid></Appid>`enter code here` <BusinessUnit></BusinessUnit> <Amount></Amount> ................ ................ </TasKInfo> `在这里输入代码`

我需要检索子元素名,而不是元素值。 我在下面附上了我的XML

 <TaskInfo>
    <Appid></Appid>`enter code here`
    <BusinessUnit></BusinessUnit>
    <Amount></Amount>
    ................
    ................
 </TasKInfo>

`在这里输入代码`
................
................

我想使用类似Xpath的方法检索TaskInfo的子元素名 阿皮德, 业务单位, 数量 ..

有人能帮我吗? 提前感谢

您可以使用
name()
功能:

  • name(/TaskInfo/*[1])
    返回
    Appid
  • name(/TaskInfo/*[2])
    返回
    BusinessUnit

    等等

XPath 2.0解决方案 返回

Appid, BusinessUnit, Amount

您可以使用local-name()
Appid, BusinessUnit, Amount