Hello Monks,
This is my first foray into using xml and perl together. I found a thread about swapping xml elements, but unlike that thread, I want to swap them out from an external file. Here is what I have so far: first, an xml file with "head" elements that I want to tag up. So, I run this:
#!/usr/bin/perl -w
use XML::Twig;
my $file = $ARGV[0];
my $twig= new XML::Twig(TwigRoots => {head => 1});
$twig->parsefile($file);
$twig->print;
which scrapes out all and only the head elements. Then I write it all to a file from the command line. That file looks something like this:
<TEI>
<head>Note VII</head>
<head>Title Page </head>
<head>Copyright Page </head>
<head>Preface </head>
...
</TEI>
Next, I retag the head elements in a text editor. Specifically, I find all roman numerals, and tag them with an xml element. I know I could do this in the script, but in this case, I want to do it by hand for oversight. So, I end up with a list of head elements, tagged as I want them, looking something like this:
<TEI>
<head>Note <romanNumeral>VII</romanNumeral></head>
<head>Title Page </head>
<head>Copyright Page </head>
<head>Preface </head>
...
</TEI>
Now, I want to go back through the file I extracted the head elements from, and replace the head tags there with the head tags I've extracted and tagged up in the external file. How would I do that?
Thanks in advance for your help!