thanks. it worked
however, i cant give xml file path instead of all the contents in the start tag 
<<

regards,
irfan



________________________________
 From: Lawrence Statton <lawre...@cluon.com>
To: beginners@perl.org 
Sent: Thursday, August 16, 2012 6:24 PM
Subject: Re: xml parsing
 
On 08/16/2012 07:46 AM, Irfan Sayed wrote:
>
>
> can you please give me sample code to store the xml contents to perl array
> using LibXML
>
> lets say xml files is as :
>
>
>   <ItemGroup>
>
>      <BuildProject Include="AssemblyInfo.csproj" />
>      <BuildProject Include="Assembly.csproj" />
>
>    </ItemGroup>
>
> regards
> irfan
>

I'm going to assume what you wanbt is the list of Included filenames...

#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;

my $XML = <<';';
  <ItemGroup>

     <BuildProject Include="AssemblyInfo.csproj" />
     <BuildProject Include="Assembly.csproj" />

   </ItemGroup>
;

my $document = XML::LibXML->load_xml(string => $XML);

my @include = map $_->findvalue('@Include'), 
$document->documentElement->findnodes('/ItemGroup/BuildProject');

use Data::Dumper;
print Data::Dumper->Dump([\@include],[qw/*include/]);

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/

Reply via email to