Ken Wolcott wrote:
I suppose it is in bad taste to reply to one's own posting, but I have an update.Hi;
I have a Fedora Core 2 full install to which I installedXML::Simple manually (ie: download, extract, perl Makefile.PL, make, make test, sudo make install). Some of the tests did not run since I did not have Tie::IxHash (?) installed. The error message (could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX) is received when I try to run the enclosed perl program using the enclosed data file. I also have enclosed the output.
Should I install Tie::IxHash? I would like to have my XML output (after values are updated) formatted the same way my XML input was formatted. Will that help?
Do I need to upgrade *XML::SAX* <http://search.cpan.org/author/MSERGEANT/XML-SAX-0.12/SAX.pm>?
Since I want the initial formatting to be retained (is this possible) and I want the XML output to pass strict XML checking, do I need to give up on XML::Simple, or did I miss some options that would give me these characteristics? I've been browsing about on CPAN for some while and there's quite a bit to research. I need to implement this quickly though...
The expected size/complexity of the input XML is quite small and simple. I just need the ability to quickly and reliably examine and possibly change the values associated with a specified set of XML tags. I need to be able to a quickly add or remove XML tags from my list to examine/modify. It looked like XML::Simple fit the bill, but I see that the XML output that the closing XML tag is not strictly compliant (as "<tag1> value </tag1>" is "correct" while "<tag1> value </>" is not). I need to preserve the XML output in ClearCase that remains in a human "readable" form, ie: well-formatted...
Thanks in advance for your comments and advice,
Ken Wolcott
********************* ?xml version="1.0" encoding="UTF-8"?> <index> <version>1.0.10.6</version> <type>acq</type> <maxhwversion>1</maxhwversion> <file>acq.img:b0e2699994df482d069d4e9d6e037abe</file> </index> *********************
********************* #!/usr/bin/perl
use strict; use warnings; use XML::Simple; use Data::Dumper;
my $label = "XXXXXXXXXXX"; # sanitized :-) my $version = substr ($label, 7, (length ($label) - 11)); my $tag; my $changes = 0; my $xml_source = "index.xml"; my $hashref = XMLin ($xml_source);
print "contents of hash prior to modification:\n"; print "#######################################\n"; print Dumper ($hashref); print "#######################################\n";
$tag = "version"; if ($hashref -> {$tag} ne $version) { $hashref -> {$tag} = $version; $changes++; }
if ($changes) { print "contents of hash after modification:\n"; print "#######################################\n"; print Dumper ($hashref); print "#######################################\n"; }
*********************
**./xml_simple.pl
could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX
contents of hash prior to modification:
#######################################
$VAR1 = {
'version' => 'XXXXXXXXXX',
'file' => 'file:md5sum',
'maxhwversion' => '1',
'type' => 'acq'
};
#######################################
contents of hash after modification:
#######################################
$VAR1 = {
'version' => 'XXXXXXXXXXXXXXXXXX',
'file' => 'file:md5sum',
'maxhwversion' => '1',
'type' => 'acq'
};
#######################################
<opt file="file:md5sum" maxhwversion="1" type="acq" version="XXXXXXXXX" />
*******************
********************* perl -v
This is perl, v5.8.3 built for i386-linux-thread-multi *********************
After reading some in the O'Reilly Perl & XML book, reading the email archives of this mailing list, several FAQS that some people mentioned from the mailing list archives and another reading of the CPAN man page for XML::Simple, I decided to try the OO interface, adding "ForceArray => 1, KeepRoot => 1, KeyAttr => 1" to my call to the parser. It seems now that the formatting is nice and the closing tag is specified properly. So, getting patient, calm, cool and collected rather than anxious solved part of the problem. Now the problem that remains is the error/warning message in the subject line: "could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX" when using XML::Simple. What do I need to do to fix that?
Thanks, Ken Wolcott
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>