Is it possible to grab a following element's attributes and use them in the preceding one like this?:
<title>Section X</title>
<paragraph number="1">Stuff</paragraph>
<title>Section Y</title>
<paragraph number="2">Stuff</paragraph>
into:
<title id="ID1">1. Section X</title>
<paragraph number="1">Stuff</paragraph>
<title id="ID2">2. Section Y</title>
<paragraph number="2">Stuff</paragraph>
I have something like this but get nodeset or string errors:
frag = Nokogiri::XML(File.open("test.xml"))
frag.css('title').each { |text|
text.set_attribute('id', "ID" + frag.css("title > paragraph['number']"))}