Matthew Ling

  • Archive
  • RSS
  • Ask me anything

Node with specific attribute

obj.xpath("//attribute[@class='metadata']")

    • #ruby
    • #nokogiri
    • #code
    • #reminder
  • 10 months ago
  • 3
  • Comments
  • Permalink
  • Share
    Tweet

Quickly parse with Nokogiri

This is a reminder for myself because I always forget the different ways for getting at data with Nokogiri.

doc = Nokogiri::XML(xml_doc)
objects = doc.xpath("//object")
value = objects.first.text
attribute = objects.first['attribute_name']
 	
    • #nokogiri
    • #xml
    • #code
    • #reminder
  • 10 months ago
  • 11
  • Comments
  • Permalink
  • Share
    Tweet

About

Dubliner in Berlin and Rails guy at Amen

Twitter

loading tweets…

  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr