in reply to Re^5: Substitution for braces
in thread Substitution for braces

#!/usr/bin/perl use strict; use warnings; my $filename = 'library.xml'; use XML::LibXML; my $parser = XML::LibXML->new(); my $doc = $parser->parse_file($filename); #my $book; foreach my $title ($doc->findnodes('/library/book/title')) { my $name= $title->to_literal ; print $name; }
Can I print just the title without giving "'/library/book/title'". There are many XML files and each have a different structure. How can I restrict to find the only the <cc> tag and get the value inside it.

Replies are listed 'Best First'.
Re^7: Substitution for braces
by Corion (Patriarch) on Jul 09, 2009 at 10:10 UTC

    Potentially you want to learn about XPath. //cc will find all <cc> nodes, wherever they live.