in reply to Problem parsing XML into arrays using XML::Simple
I would tackle that with XML::LibXML and use XPath to access the data you want. Here's how to grab the URLs out of the FragmentAssets and SiteAssets nodes.
Output:use strict; use warnings; use XML::LibXML; use Data::Dumper; my $parser = XML::LibXML->new({"encoding" => "utf-8"}); my $doc = $parser->parse_file("pm884843.xml"); my @paths = ( "/SiteStudioManifest/FragmentAssets/asset", "/SiteStudioManifest/SiteAssets/asset" ); for my $path (@paths) { my @url = map { $_->getAttributeNode("url")->getValue() } $doc->fi +ndnodes($path); print "URLs for $path:\n"; print "\t$_\n" for (@url); print "\n"; }
C:\autoworking\perl>perl pm884843.pl URLs for /SiteStudioManifest/FragmentAssets/asset: /ucm/fragments/web_header/css/nav_ie6fix.css /ucm/fragments/css4footer/img/promotions/transpare +ncy.png /ucm/fragments/css4footer/img/bg-box-menu.gif URLs for /SiteStudioManifest/SiteAssets/asset: /ucm/groups/public/@websitestructure/documents/file/pghdr_left +.jpg
You could grab the HttpSiteAddress attribute value from the root SiteStudioManifest node in a similar fashion.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem parsing XML into arrays using XML::Simple
by locked_user sundialsvc4 (Abbot) on Jan 28, 2011 at 17:30 UTC | |
|
Re^2: Problem parsing XML into arrays using XML::Simple
by tevolo (Novice) on Jan 28, 2011 at 15:48 UTC |