本文介紹了如何使用 xpath 檢索屬性名稱中包含冒號的屬性的值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個簡單的要求,我需要獲取屬性 xml:id
的值,即 af1
.我正在使用 SAXParser
,這是我的 xpath:a/aff/@xml:id
相反,我能夠獲取使用 的值xpath:a/aff/@value
.
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
.
但我無法檢索該值,您能幫幫我嗎?
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>
提前致謝.
推薦答案
要獲取可以使用的屬性值:
To get the value of the attributes you could use:
/a/aff/@*[name()='xml:id']
這篇關于如何使用 xpath 檢索屬性名稱中包含冒號的屬性的值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!