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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -