I have a simple requirement where in I need to fetch the value of attribute xml:id
i.e af1
. I am making use of a SAXParser
and here is my xpath:a/aff/@xml:id
on the contrary I was able to fetch value of using the xpath:a/aff/@value
.
我有一个简单的要求,我需要获取属性xml的值:即af1。我正在使用SAXParser,这是我的xpath:a / aff / @ xml:id相反我能够获取使用xpath的值:a / aff / @ value。
But i was unable to retrieve the value could you please help me?
但我无法找回价值,请你帮助我?
<?xml version="1.0" encoding="UTF-8" ?>
<a>
<aff xml:id="af1" value="a">
<uAff>
Hello
</uAff>
</aff>
<aff xml:id="corr1">
<uAff>
Hello1
</uAff>
</aff>
</a>
Thanks in advance.
提前致谢。
2 个解决方案
#1
13
To get the value of the attributes you could use:
要获取可以使用的属性的值:
/a/aff/@*[name()='xml:id']
#2
1
/a/aff/@xml:id works just fine in getting the values...
/ a / aff / @ xml:id在获取值时效果很好......
Are you trying to get both values?
你想要获得两个价值观吗?
If you are trying to get just the first value you could use /a/aff[1]/@xml:id
如果你想获得第一个值,你可以使用/ a / aff [1] / @ xml:id
#1
13
To get the value of the attributes you could use:
要获取可以使用的属性的值:
/a/aff/@*[name()='xml:id']
#2
1
/a/aff/@xml:id works just fine in getting the values...
/ a / aff / @ xml:id在获取值时效果很好......
Are you trying to get both values?
你想要获得两个价值观吗?
If you are trying to get just the first value you could use /a/aff[1]/@xml:id
如果你想获得第一个值,你可以使用/ a / aff [1] / @ xml:id