perlquestion
madbombX
Monks,
<p>I have been at this for much longer than should be necessary. I am using [cpan://XML::Simple], but I have also unsuccessfully tried [cpan://XML::Twig]. The file (with an example below) I have a file that looks like what is below. Each tag is only used once. I know it is possible to use a few regexen, but the way I need to use the data later, having the data in a hash similar to one returned by [cpan://XML::Simple].
<readmore>
<c>
<CVS>
$Id: File_Find.pl,v 1.1 2006-12-17 19:25:03 eric Exp $
This That <this@that.com>
Desc: Test file
</CVS>
<DATE>2006-12-10</DATE>
<INTRODUCTION>Blah, <b>blah</b>, blah</INTRODUCTION>
<TITLE>Foo</TITLE>
<AUTHOR>Bar</AUTHOR>
...
<ARTICLE>
<p>foo, test</p>
<p>bar</p>
<p>baz</p>
</ARTICLE>
</c>
</readmore>
<p>When I have the above text, all I get is what's inside of <CVS>. When I add <XML> tags surrounding the whole file, all I get is the following using [cpan://Data::Dumper]:
<readmore>
<c>
$VAR1 = \{
'CVS' => '<The entire file and this is the only tag in the hash with no other tags even making it in here>'};
</c>
</readmore>
<p>What is the best method to extract the data out of this file (either using an XML module or not) and pulling out what I need into a hash? Thanks.
<p><B>Update:</B> I forgot to include the code I actually tried. I know the <c>$file</c> is correct and <c>@articles</c> is populated.
<c>
foreach my $file (@articles) {
my $article = XMLin($file, NoAttr => 1);
use Data::Dumper;
print "<pre>", Dumper(\$article), "</pre>";
}
</c>
<p><B>Update 2:</B> I think I need to provide a better example of the data. So look above at the data example and that gives a much better perception of what I am dealing with.