Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML::XPath

Status
Not open for further replies.

donny750

Programmer
Joined
Jul 13, 2006
Messages
145
Location
FR
hello, i've this code

Code:
#!/usr/bin/perl -w

use XML::XPath;
use XML::XPath::XMLParser;


my $xp = XML::XPath->new(filename => 'client.xml');




foreach my $row ($xp->findnodes('/root/client/nom')) {
   
     my $code = $row->findvalue('information')->to_literal;
    print $code."\n";
}

my xml file
<?xml version="1.0" encoding="windows-1250"?>
<root value="x">
<entreprise>some text</entreprise>
<info></info>
<client>
<nom name="paul">
<information valeur="Niveau" type="Bon">xxx</information>
<information valeur="Solvable" type="Mauvais">zoooooooo</information>
</nom>
</client>
<client>
<nom name="albine">
<information valeur="Solvable" type="Bon">azer</information>
</nom>
</client>
<client>
<nom name="Terence">
<information valeur="Niveau" type="Tres bon"/>
<information valeur="Solvable" type="Bon"/>
<information valeur="Ancien" type="Oui"/>
</nom>
</client>
</root>
with this code i've this output
xxxzoooooooo
azer

how can i do, to obtains the value of the attibute type only for the tag information who have the attribute valeur equal to"Niveau" ?
Like this tag : <information valeur="Niveau" type="Bon">

it's possible ??
Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top