Sha256: 1e7058b7c96cf4ae783a3d35a1c1324ebe00e5cd5a4afbb48f44b72c86769053

Contents?: true

Size: 391 Bytes

Versions: 3

Compression:

Stored size: 391 Bytes

Contents

#!/usr/bin/ruby
require "#{File.dirname($0)}/../smart"

# No closure, so changes are temporary
doc = XML::Smart.open(File.dirname($0) + "/EXAMPLE.xml")
node = doc.find("/test/names/name[@team='2']").first

# add all elements that have a bigger team number as previous siblings
# (Egon is now before Kathrin in the document)
node.add_before(doc.find("/test/names/name[@team>'2']"))

puts doc

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-xml-smart-0.1.12.1-i486-linux examples/move_elements.rb
ruby-xml-smart-0.1.12-i486-linux examples/move_elements.rb
ruby-xml-smart-0.1.11-i486-linux examples/move_elements.rb