in reply to Re: Xpath value query
in thread Xpath value query
OK, so I looked at XML::Twig, and it looks like it should do what I need. My problem is, when I use the XPaths I'm being provided, I get errors.. for example running this against my example XML file.
#!/usr/opt/perl5/bin/perl -sw use XML::Twig; my $twig = XML::Twig->new(); $twig->parsefile($xmlfile); my $root = $twig->root; foreach my $i ($root->get_xpath('substring(//OLifE/Party[@id=//OLifE/R +elation[RelationRoleCode/@tc=8]/@RelatedObjectID]/Person/First Name, 1, 30)')) { print $i->{att}->{InvType}; foreach my $j ($i->get_xpath('../InvCounts/InvCount')) { print " " . $j->{att}->{Count}; } print "\n"; }
the result is this
./twigs.pl -xmlfile=a2b9f375-51fe-41a1-86ab-069561517890.xml error in xpath expression substring(//OLifE/Party[@id=//OLifE/Relation +[RelationRoleCode/@tc=8]/@RelatedObjectID]/Person/FirstName, 1, 30) a +round substring(//OLifE/Party[@id=//OLifE/Relation[RelationRoleCode/@ +tc=8]/@RelatedObjectID]/Person/FirstName, 1, 30) at ./twigs.pl line 7
So, I guess I don't understand how I would use the XPaths I've been provided. Do I have to find the attributes they referecne first, and then substitute that into the related entry in the XPath?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Xpath value query
by Corion (Patriarch) on Sep 17, 2015 at 19:02 UTC | |
by SDwerner (Initiate) on Sep 17, 2015 at 20:06 UTC | |
|
Re^3: Xpath value query
by poj (Abbot) on Sep 17, 2015 at 19:50 UTC | |
by SDwerner (Initiate) on Sep 17, 2015 at 20:23 UTC | |
by poj (Abbot) on Sep 17, 2015 at 20:58 UTC | |
by SDwerner (Initiate) on Sep 18, 2015 at 17:08 UTC | |
by poj (Abbot) on Sep 18, 2015 at 18:03 UTC | |
| |
by Anonymous Monk on Sep 18, 2015 at 22:00 UTC | |
by SDwerner (Initiate) on Sep 18, 2015 at 15:45 UTC |