2011-05-25 69 views
1

我想讀的常規XML文件,如下行代碼如何閱讀groovy中的XML文件?

def xml=new XmlSlurper().parse("C:\2011XmlLog20110524_0623") 
xml.Document.BillID.each{ 
println it} 

我收到文件未找到錯誤,雖然我有一個文件在我的C drive..is有任何語法錯誤嗎?..

憑藉超前的感謝,

拉克西米

回答

1

使用任何:

  • "C:/2011XmlLog20110524_0623"
  • "C:\\2011XmlLog20110524_0623"

反斜槓是escape character

+0

嗨,你可以請看看類似的問題嗎?(http://stackoverflow.com/questions/10278530/read-a-xml-file-in-groovy) – abi1964 2012-04-23 10:17:49