Created
November 28, 2017 11:02
-
-
Save MFQ/a92816a81738a2af1963b0749b9739ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
xml_source = '<item id="0001" type="donut"> | |
<batters> | |
<batter>Regular</batter> | |
<batter data-target="neat">Regular</batter> | |
<batter>Regular</batter> | |
</batters> | |
</item>' | |
doc = Nokogiri::XML(xml_source) | |
doc.xpath('//batter[@data-target="neat"]').first.text | |
## Will return inner text | |
doc.xpath('//batter[@data-target="neat"]').first.values | |
## Will return date-target value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment