how to get attribute values using nokogiri
===

I have a webpage whose DOM structure I do not know...but i know the text which i need to find in that particular webpage..so in order to get its xpath what i do is :

        
    doc = Nokogiri::HTML(webpage)
    doc.traverse { |node|
      if node.text?
        if node.content == "my text"
          path << node.path
        end
      end
    }
    puts path
now suppose i get an output like :: 

       html/body/div[4]/div[8]/div/div[38]/div/p/text()

so that later on when i access this webpage again i can do this ::

        doc.xpath("#{path[0]}")

instead of traversing the whole DOM tree everytime i want the text


I want to do some further processing , for that i need to know which of the element nodes in the above xpath output have attributes associated with them and what are their attribute  values. how would i achieve that?

constraints are ::I cant use any of the developer tools available in a web browser  

PS :: I am newbie in ruby and nokogiri..