def Yadis.html_yadis_location(html)
parser = HTMLTokenizer.new(html)
in_head = false
begin
while el = parser.getTag('head', '/head', 'meta', 'body', '/body',
'html', 'script')
return nil if ['/head', 'body', '/body'].member?(el.tag_name)
if el.tag_name == 'head'
unless el.to_s[-2] == ?/
in_head = true
end
end
next unless in_head
if el.tag_name == 'script'
unless el.to_s[-2] == ?/
parser.getTag('/script')
end
end
return nil if el.tag_name == 'html'
if el.tag_name == 'meta' and (equiv = el.attr_hash['http-equiv'])
if ['x-xrds-location','x-yadis-location'].member?(equiv.downcase) &&
el.attr_hash.member?('content')
return CGI::unescapeHTML(el.attr_hash['content'])
end
end
end
rescue HTMLTokenizerError
end
end