I need to create an XML element, which looks like:
<node>
<subnode attrib=1>no</subnode>
<subnode attrib=2>no</subnode>
...
</node>
To insert it into XML document. I can do that via:
node = Element.new("node")
subnode1 = Element.new("subnode")
subnode1.add_attributes("attrib", "1")
subnode1.add_text("no")
node.add_element(subnode1)
...
But it is rather uncomfortable. How could I just load an XML Element from string?
Is there something like:
my_element = <<EOF
<node>
<subnode attrib=1>no</subnode>
<subnode attrib=2>no</subnode>
</node>
EOF
node = Element.load(my_element)
No comments:
Post a Comment