Libxml (XML::Node.content)


#1

Hello all, quick question regarding XML:Node.content method.

Why content is empty for following ?

#write
doc = XML::Document.new()
doc.root = XML::Node.new(‘root_node’)
root = doc.root
root << elem1 = XML::Node.new(‘elem1’)

elem1['attr1'] = 'Value 1'
elem1.content  = 'Element 1'

doc.save('output.xml', true)

#read
doc = XML::Document.file(‘output.xml’)
doc.root.find(‘elem1’).each { |e|
puts “#{e}\t text?:#{e.text?}\t content:#{e.content}”
}

STDOUT

Element 1 text?:false content: