in reply to Re^3: perl parsing xml
in thread perl parsing xml

but i can;t hard code additionalreference2 as it could be varying. and when finally i want the output to be
semt.002.001.01 semt.002.001.01.PrvsRef semt.002.001.01.PrvsRef.Ref semt.002.001.01 semt.002.001.01.PrvsRef semt.002.001.01.PrvsRef.RefIssr semt.002.001.01.PrvsRef.RefIssr.BICOrBEI
as i explained above. first just the root , root +intermediate node, root+intermediate node+leaf

Replies are listed 'Best First'.
Re^5: perl parsing xml
by GrandFather (Saint) on Jan 23, 2008 at 06:54 UTC

    If you want people to provide an answer to help solve your problem, you have to present the problem in a lucid fashion. I have re-read all the material you have posted in this thread and still have very little idea what it is that you are trying to achieve. However if you examine the code samples I have provided above I am sure the key components of your solution are there.

    You need to have a clear idea of what the selection criteria are for the data you wish to extract before you can write the code to do that. So far, even if you know what the criteria are, you've not been able to express them clearly.


    Perl is environmentally friendly - it saves trees
      semt.002.001.01.PrvsRef.Ref semt.002.001.01.PrvsRef.RefIssr.BICOrBEI semt.002.001.01.PrvsRef.RefIssr.PrtryId.Id semt.002.001.01.PrvsRef.RefIssr.PrtryId.SchmeNm semt.002.001.01.PrvsRef.RefIssr.PrtryId.Issr semt.002.001.01.PrvsRef.MsgNm semt.002.001.01.PrvsRef.Ref semt.002.001.01.RltdRef.RefIssr.BICOrBEI semt.002.001.01.RltdRef.RefIssr.PrtryId.Id semt.002.001.01.RltdRef.RefIssr.PrtryId.SchmeNm semt.002.001.01.RltdRef.RefIssr.PrtryId.Issr semt.002.001.01.RltdRef.MsgNm
      This for the this XML structure: (only for PrvsRef & RltdRef).
      <xs:complexType name="semt.002.001.01"> <xs:sequence> <xs:element name="PrvsRef" type="AdditionalReference2" minOccurs="0" m +axOccurs="unbounded"/> <xs:element name="RltdRef" type="AdditionalReference2" minOccurs="0" m +axOccurs="unbounded"/> <xs:element name="MsgPgntn" type="Pagination"/> <xs:element name="StmtGnlDtls" type="Statement3"/> <xs:element name="AcctDtls" type="SafekeepingAccount1"/> <xs:element name="BalForAcct" type="AggregateBalanceInformation1" minO +ccurs="0" maxOccurs="unbounded"/> <xs:element name="SubAcctDtls" type="SubAccountIdentification1" minOcc +urs="0" maxOccurs="unbounded"/> <xs:element name="TtlVals" type="TotalValueInPageAndStatement" minOccu +rs="0" maxOccurs="1"/> <xs:element name="Xtnsn" type="Extension1" minOccurs="0" maxOccurs="un +bounded"/> </xs:sequence> </xs:complexType> <xs:complexType name="AdditionalReference2"> <xs:sequence> <xs:element name="Ref" type="Max35Text"/> <xs:element name="RefIssr" type="PartyIdentification1Choice" minOccurs +="0" maxOccurs="1"/> <xs:element name="MsgNm" type="Max35Text" minOccurs="0" maxOccurs="1"/ +> </xs:sequence> </xs:complexType> <xs:complexType name="PartyIdentification1Choice"> <xs:sequence> <xs:choice> <xs:element name="BICOrBEI" type="AnyBICIdentifier"/> <xs:element name="PrtryId" type="GenericIdentification1"/> <xs:element name="NmAndAdr" type="NameAndAddress2"/> </xs:choice> </xs:sequence> </xs:complexType> <xs:complexType name="GenericIdentification1"> <xs:sequence> <xs:element name="Id" type="Max35Text"/> <xs:element name="SchmeNm" type="Max35Text" minOccurs="0" maxOccurs="1 +"/> <xs:element name="Issr" type="Max35Text" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:complexType>
      semt.002.001.01 is the root node. PrvsRef, RltdRef are intermediate nodes with complex type AdditionalReference2. AdditionalReference2 has 3 names Ref, RefIssr, MsgNm. Ref is type Max35Text which is not complex type There fore is semt.002.001.01.PrvsRef.Ref. RefIssr is type PartyIdentification1Choice which again a complex type with three names. BICOrBEI, PrtryId, NmAndAdr. BICOrBEI is of the type=AnyBICIdentifier which is not a complex type. Therefor the output is semt.002.001.01.PrvsRef.RefIssr.BICOrBEI. BUt PrtryId is of the type GenericIdentification1 which has three names under it Id, SchmeNm, Issr. All of which are no longer complex types. Therefore the output is semt.002.001.01.RltdRef.RefIssr.PrtryId.Id semt.002.001.01.RltdRef.RefIssr.PrtryId.SchmeNm semt.002.001.01.RltdRef.RefIssr.PrtryId.Issr I tried the tips which you told me. But doesn't work the same way. As here it is in form of a tree. Apologies if I was not clear. Please advise.