I encounter problems in my try to extract datas from an XML file. I'm a bit in a urge so don't have much time to get this done so I would greatly appreciate your help!
My XML structure is like this :
<DSExport> <Header CharacterSet="ENGLISH" ExportingTool="Ascential DataStage E +xport" ToolVersion="4" ServerName="VILLETTE" ToolInstanceID="Portage" + Date="2006-03-29" Time="10.00.34" ServerVersion="7.5.1.A"/> <Job Identifier="adresses" DateModified="2006-03-28" TimeModified=" +17.15.15"> <Record Identifier="ROOT" DateModified="1899-12-30" TimeModified +="00.00.01" Type="JobDefn" Readonly="0"> <Property Name="Name">adresses</Property> <Property Name="Description">DFE/ job of addresses MAJ - 18/1 +1/2004</Property> <Property Name="NextID">2</Property> <Property Name="Container">V0</Property> <Property Name="FullDescription" PreFormatted="1"> RD/ Preprod ok - 15/05/2001 (!!!perf on upd?) Modified by LCO : 19/06/2001: Use system_origin as parameter Modified by LCO : 22/06/2001: Retreive Country Short Name Modified by EPE : 17/02/2004: ajout de la notion Sales Territory (Coun +try, region, sector) Modified by EPE : 19/02/2004: ajout de la notion Salesrep_id Modified by DFE : 18/11/2004: modification des requetes ar_ra_adresses +_n_phone et oa_ra_territories: ajout de comparaison avec la last_upda +te_date de HZ_CUST_SITE_USES_ALL </Property> <Property Name="JobVersion">50.0.0</Property> <Property Name="ControlAfterSubr">1</Property> <Collection Name="Parameters" Type="Parameters"> <SubRecord> <Property Name="Name">$GV_Portage_Rejects_Pathname</Pro +perty> <Property Name="Prompt">GV Portage Rejects Pathname</Pr +operty> <Property Name="Default">F:\Projects\BI_Interfaces\Port +age\Rejects</Property> <Property Name="ParamType">0</Property> <Property Name="ParamLength">0</Property> <Property Name="ParamScale">0</Property> </SubRecord> <SubRecord> <Property Name="Name">$GV_Portage_Hash_Pathname</Proper +ty> <Property Name="Prompt">GV Portage Hash Pathname</Prope +rty> <Property Name="Default">F:\Projects\BI_Interfaces\Port +age\Hash\</Property> <Property Name="ParamType">0</Property> <Property Name="ParamLength">0</Property> <Property Name="ParamScale">0</Property> </SubRecord> <Record Identifier="V0S0P1" DateModified="1899-12-30" TimeModifi +ed="00.00.01" Type="CustomOutput" Readonly="0"> <Property Name="Name">li_hf_adresses</Property> <Property Name="Partner">V0S1</Property> <Collection Name="Properties" Type="CustomProperty"> <SubRecord> <Property Name="Name">TABLE</Property> <Property Name="Value">APPS.RA_ADDRESSES_ALL</Property> </SubRecord> <SubRecord> <Property Name="Name">GENSQL</Property> <Property Name="Value">Yes</Property> </SubRecord> <SubRecord> <Property Name="Name">USERSQL</Property> <Property Name="Value" PreFormatted="1"> SELECT ADDRESS_ID,LAST_UPDATE_DATE,LAST_UPDATED_BY,CREATION_DATE,CREAT +ED_BY,COUNTRY,ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4,CITY,POSTAL_CODE,ST +ATE,PROVINCE,COUNTY FROM APPS.RA_ADDRESSES_ALL WHERE LAST_UPDATE_DATE +>=(SELECT LAST_LOADING_DATE from DWADMIN.INT_LOADINGS@#DB_LINK# WHERE TABLE_NAME = 'CUS_ADDRESSES' AND SYSTEM_ORIGIN = '#system_origin#' ) </Property> </SubRecord> <SubRecord> <Property Name="Name">ARRAYSIZE</Property> <Property Name="Value">32000</Property> </SubRecord> <SubRecord> <Property Name="Name">WHERE_CLAUSE</Property> <Property Name="Value" PreFormatted="1"> LAST_UPDATE_DATE>=(SELECT LAST_LOADING_DATE from DWADMIN.INT_LOADIN +GS@#DB_LINK# WHERE TABLE_NAME = 'CUS_ADDRESSES' AND SYSTEM_ORIGIN = &apos +;#system_origin#' ) or (select max(last_update_date) from apps.HZ_CUST_SITE_USES_ALL where cust_acct_site_id = RA_ADDRESSES_ALL.address_id) >=(SELECT LAST_LOADING_DATE from DWADMIN.INT_LOADINGS@#DB_LINK# WHERE TABLE_NAME = 'CUS_ADDRESSES' AND SYSTEM_ORIGIN = &apo +s;#system_origin#') </Property> </SubRecord> ...
My objective :
I would like to access the job name, wich is the Job identifier.
The I would like to grab names like
<Property Name="Name">li_hf_adresses</Property>
The rule is that if the subrecord contains the property Named TABLE, I would like to retrieve the Values that comes next. Same thing if the property name is USER SQL.
But I can't figure out what's the elements name. I tried with childrens or Twig/Headers but no good.
Could someone give me a clue please?
Thanks in advance!
Here is my perl code:
#!/bin/perl -w use strict; use XML::Twig; my $t= new XML::Twig( TwigHandlers=> { job => \&job}); $t->parsefile( 'T:\\BI\\Jerome\\xml\\tree.xml'); exit; sub job { my ($t, $job)= @_; my %job; $job{Attr_name}= join ':',map {$_->text || ''} @{[$job->children( +'Name')]}; $job{Attr_value}= join ':',map {$_->text || ''} @{[$job->children( + 'Value')]}; print "$job{Attr_name}: $job{Attr_value}\n"; $job->delete; }
20060401 Janitored by Corion: Put XML into readmore tag
In reply to XML::Twig usage incomprehension by Jerome
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |