in reply to Re^2: Xpath value query
in thread Xpath value query
I don't know what you are trying to extract but here's a simple example to get you started
Ouput should be#!perl use strict; use XML::Twig; my $twig = XML::Twig->new(); $twig->parsefile('txlife.xml'); my $root = $twig->root; my @nodes1 = $root->get_xpath('//Holding'); for my $hold (@nodes1){ print "\nId = ".$hold->att('id')."\n"; my @nodes2 = $hold->get_xpath('Policy/KeyedValue/KeyValue'); for my $_ (@nodes2){ print $_->prev_sibling_text." = "; print $_->text."\n"; } }
pojId = Holding_aa2b0594-77d6-4264-b277-0218e852cb36 AccountType = Individual CheckIndicator = No 1035ExchangeIncluded = No SponsorName = InsCompany Id = Holding_f2cfb5bd-6009-4bf2-95a0-686cb69a3b7a OldProductType = 401K
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Xpath value query
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 SDwerner (Initiate) on Sep 18, 2015 at 18:44 UTC | |
| |
by Anonymous Monk on Sep 18, 2015 at 22:00 UTC | |
by SDwerner (Initiate) on Sep 18, 2015 at 15:45 UTC |