Sha256: fa4009f25546b4dd4fc980cb1aba91f45a0883943e43771cac01a3d4c4e9b6f9

Contents?: true

Size: 787 Bytes

Versions: 22

Compression:

Stored size: 787 Bytes

Contents

require File.expand_path(::File.dirname(__FILE__) + '/../lib/xml/smart')
require File.expand_path(::File.dirname(__FILE__) + '/smartrunner.rb')

class TestXpathAttrs < Minitest::Test
  def test_xpath_attrs
    doc = XML::Smart.open(::File.dirname(__FILE__) + "/EXAMPLE.xml")
    node = doc.root.find("/test/names/name[2]/@team").first
    
    assert(node.qname == "team")

    # print attribute name and value
    assert(node.qname + "=" + node.value == 'team=1')
    assert(node.qname + "=" + node.to_s == 'team=1')
    
    # set the value of the attribute
    node.value = "Value"
    assert(node.value == 'Value')
    
    doc.root.find("/test/names/name[2]/@team").first.value = "Hi all"
    assert(doc.root.find("/test/names/name[2]/@team").first.value == 'Hi all')
  end  
end  

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
xml-smart-0.5.3 test/tc_xpath_attrs.rb
xml-smart-0.5.2 test/tc_xpath_attrs.rb
xml-smart-0.5.1 test/tc_xpath_attrs.rb
xml-smart-0.5.0 test/tc_xpath_attrs.rb
xml-smart-0.4.4 test/tc_xpath_attrs.rb
xml-smart-0.4.3 test/tc_xpath_attrs.rb
xml-smart-0.4.2 test/tc_xpath_attrs.rb
xml-smart-0.4.1 test/tc_xpath_attrs.rb
xml-smart-0.4.0 test/tc_xpath_attrs.rb
xml-smart-0.3.22 test/tc_xpath_attrs.rb
xml-smart-0.3.21 test/tc_xpath_attrs.rb
xml-smart-0.3.20 test/tc_xpath_attrs.rb
xml-smart-0.3.19 test/tc_xpath_attrs.rb
xml-smart-0.3.18 test/tc_xpath_attrs.rb
xml-smart-0.3.17 test/tc_xpath_attrs.rb
xml-smart-0.3.16 test/tc_xpath_attrs.rb
xml-smart-0.3.15 test/tc_xpath_attrs.rb
xml-smart-0.3.14 test/tc_xpath_attrs.rb
xml-smart-0.3.12 test/tc_xpath_attrs.rb
xml-smart-0.3.11 test/tc_xpath_attrs.rb