我有一个包含以下数据的text / xml文件
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<GovernmentPolicy>
<name>Sample Policy</name>
<description>Policy set during enrollment</description>
<Resources>
<ResourceID>7619f915-420d-4220-993e-1d3f1bee0ba4</ResourceID>
</Resources>
<GovernmentPolicy>
我想在我的厨师食谱中阅读以下内容,所以我有这个。我想得到价值“7619f915-420d-4220-993e-1d3f1bee0ba4” 所以我通过我的正则表达式来运行它。我不知道为什么我无法与之匹敌。
ruby_block "Read GovernmentPolicy" do
block do
resourceID = ""
governmentpolicies = "/temp/governmentpolicies.xml"
if File.exists?("#{governmentpolicies}")
f = File.open("#{governmentpolicies}", 'r')
pattern = /^\<ResourceID\>/
f.each {|line|
if pattern.match(line)
puts("***************MATCH FOUND*******************")
puts line
end
}
f.close
end
end
end
任何提示?