Sha256: 4e7b71ee6940527efb701428b72eb8b9a03e3bcd78a8cd327c2a63433dbb90c9

Contents?: true

Size: 583 Bytes

Versions: 3

Compression:

Stored size: 583 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")

# add a node with namespace
nsnode = doc.root.add("hallo")
ns = nsnode.namespaces.add("test","http://heise")
nsnode.add("test:entry")

# find node
puts "Find 1: #{doc.find("test:node").empty?}" rescue puts "Find 1: undefined namespace prefix"
puts "Find 2: #{doc.find("test:node",{"test" => "http://heise"}).empty?}"

doc.namespaces = {"t" => "http://heise"}
puts "Find 3: #{doc.find("t:node").empty?}"

# print document
puts doc

Version data entries

3 entries across 3 versions & 1 rubygems

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