On Saturday 02 Apr 2005 04:29, Johnstone, Colin wrote:
> Gidday All,
>
> I would like to use xml Parser to parse this chunk of xml (below) and
> return the business unit name and id attributes for each of the elements
> where division id = '221'
>
> I have tried

Why not try:

http://search.cpan.org/~grantm/XML-Simple-2.14/lib/XML/Simple.pm

If all you want to do is grab a business unit, follow the example on the page 
above.

>
> #!/web/Interwoven/TeamSite/iw-perl/bin/iwperl
>
> use XML::XPath;
> use XML::XPath::XMLParser;
>
> my $xpath;
> my $nodeset;
> my @memberList;
> my $arg;
> my $argVal;
>
> my $fileToParse =
> qq[/web/Interwoven/TeamSite/custom/config/DET_structure.xml];
>
> $xpath       = XML::XPath->new( filename => "$fileToParse" );
> $nodeSet     = $xpath->find( $xpathQuery );
> @memberList  = map { XML::XPath::XMLParser::as_string( $_ ) }
> $nodeSet->get_nodelist();
> @memberList  = map { s|^.*(?=htdocs)||; $_; } @memberList;
> @memberList  = map { s|//|/|g; $_; } @memberList;
> # %masterList  = map {  $_, 1  } @memberList;
>
> while( @memberList ){
>
>       print( $_ . '\n' );
>
> }
>
> Any help appreciated
> Cheers
> Colin
>
> <?xml version="1.0" encoding="UTF-8"?>
> <organisation lastUpdate="21/03/05">
>       <division name="Office of the Director-General" id="202">
>               <business-unit name="Correspondence unit" id="203"/>
>       </division>
>       <division name="Office of the Deputy Director-General"
> id="276"/>
>       <division name="Strategic Communications and Marketing"
> id="204">
>               <business-unit name="Communications unit" id="1002"/>
>       </division>
>       <division name="Strategic Legal  Unit" id="1003"/>
>       <division name="Internal Audit" id="222"/>
>       <division name="Strategic Infrastructure Initiatives"
> id="1022"/>
>       <division name="Human Resource Strategy and Performance"
> id="221">
>               <business-unit name="Workforce Capability" id="214"/>
>               <business-unit name="Ethics" id="214C"/>
>               <business-unit name="eDRMS Project" id="1024"/>
>               <business-unit name="Workforce Management" id="216"/>
>               <business-unit name="Strategic Legal and FOI"
> id="1003"/>
>               <business-unit name="HR Strategy and Information Policy
> and Reporting - name may change" id="221">
>                       <sub-business-unit name="HR Business/Workforce
> Planning" id="1024"/>
>                       <sub-business-unit name="HR Strategy"
> id="1025"/>
>                       <sub-business-unit name="HR
> Governance/Governance Structures" id="1026"/>
>                       <sub-business-unit name="HR Reporting"
> id="1027"/>
>                       <sub-business-unit name="HR Business Performance
> and Analysis" id="1028"/>
>                       <sub-business-unit name="HR Information System
> Protocols" id="1029"/>
>               </business-unit>
>               <business-unit name="Office of the GM (HR)" id="1005"/>
>       </division>
> </organisation>
>
> **********************************************
> Colin Johnstone
> Independent Interwoven Teamsite Analyst Programmer (Contractor)
> eGovernment Delivery Team
> Department of Employment and Training
> Phone         (07) 3244 6268
> Fax   (07) 3244 6265
> Email Colin.Johnstone <mailto:[EMAIL PROTECTED]>
> Web   www.trainandemploy.qld.gov.au
> <http://www.trainandemploy.qld.gov.au/>
> Address       417 Main Street, Kangaroo Point 4169, QLD, Australia.
> **********************************************
>
>
> ---------------------------------------------------------------------------
>----- This E-Mail is intended only for the addressee. Its use is limited to
> that intended by the author at the time and it is not to be distributed
> without the author's consent. Unless otherwise stated, the State of
> Queensland accepts no liability for the contents of this E-Mail except
> where subsequently confirmed in writing. The opinions expressed in this
> E-Mail are those of the author and do not necessarily represent the views
> of the State of Queensland. This E-Mail is confidential and may be subject
> to a claim of legal privilege.
>
> If you have received this E-Mail in error, please notify the author
> and delete this message immediately.
> ---------------------------------------------------------------------------
>----- !DEPTSTAMP1!

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to