> I am trying to replace every <td> element that has a colspan of X
> with X many identical <td> elements, each without a colspan attribute.
>
> Along the way, I create a loop in which I duplicate the <td> X-1
> many times.
>
> First I find the <td> and assign it to a local variable called td.
>
> In the rails server debugger, I can see that:
>
> (rdb:60) td.class
> Nokogiri::XML::Element
>
> Then I try:
>
> td.add_next_sibling(td)
This is telling Nokogiri to take an element, and move that element to
be after itself. It's not adding a new instance of the td "factory"
object.
For that, you need some variation on:
nxt = Nokogiri::XML::Node.new( "td", doc )
td.add_next_sibling(nxt)
The first line creates a new element on the current document (the doc
variable should be replaced with whatever you call your document in
your script) and the second line puts it where you expect it to go.
>
> But I just get the error:
>
> Could not reparent node (RuntimeError)
Think about td as being a single object in physical space, and this
will make total sense. You can't move something to be after itself,
because the moment you start to move it, you have no idea what the
destination should be.
Walter
>
> Why is this? How do I fix it?
>
> Sorry I couldn't find this error in the rdoc.
>
> Thanks,
>
> Steven.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "nokogiri-talk" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/nokogiri-talk/-/ZWxxMFlaQlkzam9K
> .
> To post to this group, send email to nokogi...@googlegroups.com.
> To unsubscribe from this group, send email to nokogiri-tal...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/nokogiri-talk?hl=en
> .