0
groovy에서 XMLSlurper를 통해 xml을 구문 분석하는 이상한 문제가 발생했으며 크기를 0으로 표시합니다. 이유를 파악할 수 없습니다.XML을 통해 Groovy에서 XML 구문 분석
내 XML 파일과 같이 보인다 :
<?xml version="1.0" encoding="iso-8859-1"?>
<sites>
<site name="OctUK">
<property name="warName">OctUKbuild-Deployable</property>
</site>
<site name="GbsJP">
<property name="warName">GbsJPbuild-Deployable</property>
</site>
</sites>
코드 :이 0으로 siteGPath의 결과를 제공하기 때문에 어떤 사이트가 발견되지 :
findSite("${project.GTA_BUILD_HOME}/platforms/pos/config/pos-sites.xml")
//Passed the path of the xml file to the method below:
GPathResult findSite(String sitesXml) {
xmlConfig = new XmlSlurper().parse(new File(sitesXml))
def siteGPath = xmlConfig.sites.site.findAll
// Check that a POS-sites.xml is valid
assert siteGPath.size() != 0, 'Error: no site found'
return(siteGPath)
}
방법은 오류가 오류라고 실패합니다. 왜 결과가 0인지 알려지지 않습니다. 크기는 2로 지정해야합니다.
잘못된 것이 있습니까? 어떤 도움이라도 대단히 감사합니다. 나는이 시점에서 붙어있다.
감사합니다. Tim. 나는 이제 siteGPath = xmlConfig.site를 def로 내 코드를 수정했다. – user1470220