Merging xml elements with nokogiri
I am trying to get the content of an XML:开发者_运维技巧:Element type. I have tried the content method, but that gives me the text and I am not just interested in the text.
The XML element I have has tags, and I don't want to lose that information. For example, Suppose XML::Element myElement has:
<block>
element has other tags like <tag> ... </tag>
<a href ... > </a> ...
<blah> </blah>
etc..
</block>
So I want a method that will return:
element has other tags like <tag> ... </tag>
<a href ... > </a> ...
<blah> </blah>
etc..
Ultimately, I want to use this to actually merge XML elements into one. If there exists such method already let me know or if you have a nice approach to merge them effectively. As an example,
I have two blocks
<block>
block 1 has tags like <tag> ... </tag>
<a href ... > </a> ...
<blah> </blah>
etc..
</block>
<block>
block 2 has tags like <tag> ... </tag>
<a href ... > </a> ...
<blah> </blah>
etc..
</block>
and would want to have it all in one block as follows:
<block>
block 1 has tags like <tag> ... </tag>
<a href ... > </a> ...
<blah> </blah>
etc..
block 2 has tags like <tag> ... </tag>
<a href ... > </a> ...
<blah> </blah>
etc..
</block>
Any help appreciated,
Ted
Ah just realized how to get the information inside a two tags
puts xmlelement.inner_html
精彩评论