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 ________________________________ From: Shlomi Fish <shlo...@shlomifish.org> To: Irfan Sayed <irfan_sayed2...@yahoo.com> Cc: "beginners@perl.org" <beginners@perl.org> Sent: Thursday, August 16, 2012 6:07 PM Subject: Re: xml parsing Hi Irfan, On Thu, 16 Aug 2012 04:55:33 -0700 (PDT) Irfan Sayed <irfan_sayed2...@yahoo.com> wrote: > hi, > > i need to parse the xml file and store the data in array : > > here is the code: > use XML::Simple; > > my $ItemGroup = XMLin('C:\Users\bvcontrolbuild\Desktop\data.xml'); > > foreach my $BuildProject (@{$ItemGroup->{BuildProject}}) { > print $BuildProject->{Include} . "\n"; > } > Please don't use XML::Simple to parse XML. See: * http://perl-begin.org/uses/xml/ <rindolf> xml <perlbot> Don't parse XML with regex! Use a real parser. Avoid XML::Simple (see the xml::simple factoid). Choices are ::Easy, ::Smart, ::TreeBuilder, ::Twig for simple stuff. LibXML is a good general purpose starting point. See also XML::All. http://perl-xml.sf.net/faq/ <rindolf> xml::simple <perlbot> XML::Simple commits the fatal flaw of trying to massage complicated and often irregular XML into the simple and highly regular world of perl data structures. Irregularities cause "not a hashref" sort of errors in your program. Use a real parser. see: xml In a post to the perl-xml mailing list, XML::Simple's originator and maintainer noted he can no longer recommend XML::Simple either. So please use a different and more robust alternative. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ "The Human Hacking Field Guide" - http://shlom.in/hhfg He says “One and one and one is three”. Got to be good‐looking ’cause he’s so hard to see. — The Beatles, “Come Together” Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/