I have a hashes.xml on a location on the web. I want to parse it for the fields name='hash'><string>78235A2449BA7188CBF95F7DD2D40A36</string>
, the file has many fields with this pattern (the MD5 hash is only an example, they differ in the XML document), I want to get them all and print to stdout. As far as I get is to fetch the first occurence and print it out then I'm stuck.
for locale in (locales)
while hash.nil? do
headers = {
'Host' => server,
'Content-Type' => 'application/x-www-form-urlencoded',
'Content-Length' => locale.length.to_s,
}
resp, data = http.post(path, locale, headers)
# Extract the hash
data =~ /name='hash'\>\<string\>([A-F0-9]+).*\<\/string\>/m
hash = $1
mylocale = locale
break if hash.nil?
end
end
if hash.nil?
puts "ERROR"
exit(1)
end
puts "Hash: "+hash