2012-06-23 41 views
0

我產生我的構建過程中EMMA報告,他們看起來像這樣的XPath艾瑪的概述值報告

<report> 
    <stats> 
    <packages value="110"/> 
    <classes value="1762"/> 
    <methods value="12617"/> 
    <srcfiles value="962"/> 
    <srclines value="61320"/> 
    </stats> 
    <data> 
    <all name="all classes"> 
     <coverage type="class, %" value="2% (42/1762)"/> 
     <coverage type="method, %" value="2% (302/12617)"/> 
     <coverage type="block, %" value="3% (6849/258033)"/> 
     <coverage type="line, %" value="3% (1592.9/61320)"/> 

我需要從/報告/數據/所有/覆蓋節點的值屬性的百分比。目前讓這些:

Invalid XPath expression: "/report/data/all/coverage[starts-with(@type,'block')]@value": Unexpected '@' 
Invalid XPath expression: "substring-before(/report/data/all/coverage[starts-with(@type,'block']@value,'%')": Expected:) 

回答

2

@value屬性之前你缺少從XPath的斜槓。還有一個缺少括號在開始,與功能

請嘗試以下

/report/data/all/coverage[starts-with(@type,'block')]/@value 


substring-before(/report/data/all/coverage[starts-with(@type,'block')]/@value,'%') 
+0

這是它,謝謝! –