Jump to content

XML searching


cignaj

Recommended Posts

Hello all,I am sure there is a rather easy way to do this, but I haven't been able to figure it out as I am rather new to XML searching and such. Here is a snippet of the XML I am working with and below is what I am looking for...

ACORD>- <InsuranceSvcRs>  <RqUID />   - <PersAutoPolicyAddRs>    <RqUID />     <com.csc_CompanyURL />     <TransactionResponseDt />     <TransactionEffectiveDt />     <CurCd>USD</CurCd>     <Producer />     <InsuredOrPrincipal />     - <PersPolicy>      - <ContractTerm>        <EffectiveDt>09/18/2007</EffectiveDt>         <ExpirationDt>09/18/2008</ExpirationDt>         </ContractTerm>      </PersPolicy>    </PersAutoPolicyAddRs>  - <PersAutoPolicyAddRq>    <RqUID>50412834672401993702</RqUID>     <TransactionRequestDt>2007/09/19</TransactionRequestDt>     <TransactionEffectiveDt />     <CurCd />     <Producer />     <InsuredOrPrincipal />     - <PersPolicy>       - <ContractTerm>         <EffectiveDt>2007/09/18</EffectiveDt>          <ExpirationDt>2008/09/18</ExpirationDt>          </ContractTerm>       </PersPolicy>    <RemarkText />     </PersAutoPolicyAddRq>  </InsuranceSvcRs></ACORD>

I am trying to get to the EffectiveDt found within the PersAutoPolicyAddRq tree ... however, I cannot use strictly PersAutoPolicyAddRq because that specific node may also at times be called PersAutoPolicyQuoteRq or something similar. I tried using a "wildcard" character but it would not work ... I tried !//InsuranceSvcRs/PersAuto*Rq//PersPolicy//ContractTerm//EffectiveDt it does not return the data ... I tried !//InsuranceSvcRs/*Rq//PersPolicy//ContractTerm//EffectiveDt and it returns the data from the first EffectiveDt node found within the PersAutoPolicyAddRs tree.Any help would be appreciated!Thanks!

Link to comment
Share on other sites

By using the Union operator you can test for the union of both (or more) of these nodes and then select the last of the union. If, as you said, the node may be named different based on the situation, it will find at least one<xsl:value-of select="(//PersAutoPolicyAddRq | //PersAutoPolicyQuoteRq)[last()]//EffectiveDt"/>The pipe is the union operator, it creates a node list of all the nodes that match the criteria. In this case all nodes called 'PersAutoPolicyAddRq' and all nodes called 'PersAutoPolicyQuoteRq'. If then applies the condition [last()] to the node-set to get the last one found. After that it searchs for the EffectiveDt node of whatever one was there.Hope it helps some.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...