ruby - Extract attribute value from XML in JRuby -
i need extract value of attribute. xml below need extract value '9'.
xmldoc = <?xml version='1.0' encoding='utf-8'?><config version='9'><roaming>false</roaming></config>
i using code getting whole xml instead of value.
xpath.match(xmldoc, "/config[@version]")
you can use
require 'active_support/core_ext/hash' hash.from_xml(xmldoc)['config']['version']
Comments
Post a Comment