Re: Accessing multiple nodes(?)
by John van Krieken other posts by this author
Jun 28 2005 12:53AM messages near this date
view in the new Beta List Site
Accessing multiple nodes(?)
|
Re: Accessing multiple nodes(?)
& XSLT On Mon, 27 Jun 2005 17:42:52 -0700 (PDT)
"Roderick A. Anderson" <raanders@[...].org> wrote:
Sorry, the previous was a bit too terse I'a afraid, anottation in the
code:
> Really sorry to throw this out but I've spent most of today and some
> of last Friday trying to figure out how to do this , but have no joy.
>
> I have the results of a query of an accounting system and it has
> information for multiple details that I'd need to pull.
>
> Here is a portion of the document.
>
> <Response>
> <Body>
> <QueryCustomerResponse>
> <c:Customer>
> <!-- Starting here -->
> <sd:ServicePlan>
> <sd:ServicePlanID>666</sd:ServicePlanID>
> <sd:Services>
> <sd:Service>
> <sd:ServiceID>42</sd:ServiceID>
> <sd:ServiceDescription ServiceName="Dialin"/>
> <sd:Properties>
> <b:Property>
> <b:PropertyID>1024</b:PropertyID>
> <b:PropertyDescription PropertyName="UserName"/>
> <b:Value>juser</b:Value>
> </b:Property>
> <b:Property>
> <b:PropertyID>64</b:PropertyID>
> <b:PropertyDescription PropertyName="Password"/>
> <b:Value>testing</b:Value>
> </b:Property>
> </sd:Properties>
> <sd:ServiceStatus Status="0" Type="suspended"/>
> <sd:ServiceProvider ServiceProviderID="0"/>
> </sd:Service>
> </sd:Services>
> </sd:ServicePlan>
> <!-- This type of block/node repeats may times -->
> </c:Customer>
> </QueryCustomerResponse>
> </Body>
> </Response>
>
> Rather than bore you with my many "wrong" trys I'll just throw this
> bit I thought should work and ask for a clue-stick.
>
> use XML::XPath;
>
> my $xp = XML::XPath->new( filename => 'all.xml' );
>
> my $nodeset = $xp->find( '//sd:ServicePlanID' );
>
> foreach my $node ( $nodeset->get_nodelist ) {
> print $xp->findnodes( '//b:PropertyDescription[@PropertyName =
> "UserName"]' ) , "\n";
print $xp-> findvalue( './/b:PropertyDescription[@PropertyName =
"UserName"]', $node ) , "\n";
> #-# I really only want the Value that goes with this Property
> }
>
>
> Rod
> --
> "Open Source Software - You usually get more than you pay for..."
> "Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL"
>
>
> _______________________________________________
> Perl-XML mailing list
> Perl-XML@[...].com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
--
John van Krieken, AT Computing BV, 024-3527242
john@[...].nl, http://www.ATComputing.nl/images/pasfotos/john.jpg
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Roderick A. Anderson
John van Krieken
Roderick A. Anderson
Tod Harter
Roderick A. Anderson
Duncan Cameron
Roderick A. Anderson
John van Krieken
|