tonyz has asked for the wisdom of the Perl Monks concerning the following question:
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:#!/usr/bin/perl -w use XML::Twig; my $file = $ARGV[0]; my $twig= new XML::Twig(TwigRoots => {head => 1}); $twig->parsefile($file); $twig->print;
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 VII</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!<TEI> <head>Note <romanNumeral>VII</romanNumeral></head> <head>Title Page </head> <head>Copyright Page </head> <head>Preface </head> ... </TEI>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Swapping xml elements from an external file?
by Fletch (Bishop) on Oct 06, 2008 at 22:02 UTC | |
|
Re: Swapping xml elements from an external file?
by Jenda (Abbot) on Oct 06, 2008 at 22:28 UTC | |
|
Re: Swapping xml elements from an external file?
by GrandFather (Saint) on Oct 06, 2008 at 22:49 UTC |