解析时的XmlSlurper问题

时间:2017-04-11 14:27:21

标签: groovy xmlslurper

我有如下的XML,

<div class="storeContainer">
      <div class="storeCount">50</div>
      <div class="mapAddress" id="store50">
         <h4 onclick="changeMap(50,38.872432,-78.530463);">Woodstock, VA</h4>
         <h5>Woodstock Square</h5>467 West Reservoir Road
<br/>540-459-7505
<br/>
         <a href="https://maps.google.com/maps?saddr=geo&amp;daddr=467+West+Reservoir+Road+Woodstock+VA+22664&amp;sll=38.872432,-78.530463&amp;sspn=0.011265,0.014098&amp;z=12"
            class="getDirections">Get Directions</a>
      </div>
   </div>
</div>

我想阅读地址详情并使用

def envelope = new XmlSlurper().parseText(response.toString());
        envelope.'**'
        .each {
            println it.h4.text()
            println it.h5.text()

            println it.a.@'href'    
        }

获取价值,但我不知道如何获得 467 West Reservoir Road 540-459-7505

1 个答案:

答案 0 :(得分:1)

如果您切换到.left:after { background-color:lightblue; left: -999em; content: ''; display: block; position: absolute; width: 999em; top: 0; bottom: 0; } .right:after { background-color:#4444ff; right: -999em; content: ''; display: block; position: absolute; width: 999em; top: 0; bottom: 0; } ,则可以执行以下操作:

XmlParser