in reply to Having problems accessing individual attributes in xml
Update: Here's an example using sample xml from XML::XPath:
test.xml#!/usr/bin/perl use strict; use warnings; use XML::XPath; use XML::XPath::XMLParser; my $file = 'test.xml'; my $xp = XML::XPath->new( filename => $file ); my $nodeset = $xp->find('//employee'); foreach my $node ($nodeset->get_nodelist) { print XML::XPath::XMLParser::as_string($node), "\n\n"; }
<?xml version="1.0" encoding="ISO-8859-1"?> <timesheet xmlns:a="www" xmlns:b="xxx" xmlns="fred"> <employee> <name> <forename>Matt</forename> <surname>Sergeant</surname> </name> <department>Development IT</department> </employee> <rules> <rule>NextRule1</rule> <rule>NextRule2</rule> </rules> <projects> <project a:Name="Consultancy > fred" b:Name="Fred"> <sunday>0.00</sunday> <monday>0.00</monday> <tuesday>7.75</tuesday> <wednesday>8.75</wednesday> <thursday>7.75</thursday> <friday>6.5</friday> <saturday>0.00</saturday> </project> <project Name="Holiday"> <sunday>0.00</sunday> <monday>7.75</monday> <tuesday>0.00</tuesday> <wednesday>0.00</wednesday> <thursday>0.00</thursday> <friday>0.00</friday> <saturday>0.00</saturday> </project> </projects> </timesheet>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Having problems accessing individual attributes in xml
by Gemenon (Initiate) on Oct 21, 2010 at 03:09 UTC | |
by dasgar (Priest) on Oct 21, 2010 at 04:49 UTC | |
by Gemenon (Initiate) on Oct 21, 2010 at 22:19 UTC |