I discovered one more wrinkle. I didn't think the label_y blocks at the top of the file were important, but it turns out they are. Remember the format of those is:
<label_y="somevalue"> <label_z>a value</label_z> <label_z>a value</label_z> <label_z>a value</label_z> <label_z>a value</label_z> </label_y>
What I need to do is this:
Discard all but the first (or last, doesn't matter) of these, so there is only one such block in the file. Or, discard all of them and create a replacement - it would not really matter, just so there is only one.
If keeping one of the original blocks, save "somevalue" from the first line in a variable such as $somevalue.
Then, lower in the program, before writing the "kept" label_a blocks to the output file, I need to do this:
$e->set_att( 'channel' => $somevalue );Since what's been posted so far is far more elegant than anything I would have come up with, I'd be interested in knowing a good way to do discard all (or all but one) of those initial blocks, and insert a replacement if needed, so there is only one.
By the way, relative to my previous post I did discover keep_atts_order => 'TRUE', which works in Linux but for some reason not in ActivePerl in Windows.
In reply to Re^3: How can I keep or discard certain blocks of an XML file based on first line of block?
by Anonymous Monk
in thread How can I keep or discard certain blocks of an XML file based on first line of block?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |