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

javascript - Training Neural Network to play flappy bird with genetic algorithm - Why can't it learn? -

service - Android MediaPlayer calls onCompletion before it already finished -

javascript - Create a stacked percentage column -