So:

node1 = XML::Node.new('foo')
node1 << 'bar'

would produce '<foo>bar</foo>' and not '<foo/>bar'.  However:

node2 = XML::Node.new('bar')
node1 << node2

should produce '<foo><bar/></foo>'.

If the argument to << is a string, append to the xmlNode->content via xmlNodeAddContent(3). If, however, the argument is an XML::Node, then use xmlAddChild(3) to add an xmlNode->child node.


+ and << should behave differently:

'node1 + node2' should produce '<foo/><bar/>'

Yes, that is how it currently works.  Note if you do this:

node1 = XML::Node.new('foo')
node1 << '<bar/>'

You get this:

<foo>&lt;bar/&gt;</foo>

Which seems fine to me.

However, that doesn't really help with this issue:

node = XML::Node.new('foo') << XML::Node.new('bar') << XML::Node.new('baz')

If << returns self, then you get:

'<foo><bar/><baz/></foo>' where node points to foo

If << returns the appended child, then:

'<foo><bar><baz/></bar></foo>' where node points to baz. Its the pointing to baz bit I don't like.

Charlie

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to