libxml (XML::Node.content)

K

Kuba Podgorski

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

Why content is empty for following <code>?


#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:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top