简体   繁体   中英

Get text value of node based on another node text in xslt

I have an xml with the following example format

<?xml version="1.0" encoding="ISO-8859-1"?>
<EnvioDTE version="1.0" xmlns="http://www.sii.cl/SiiDte" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sii.cl/SiiDte EnvioDTE_v10.xsd">
<SetDTE ID="SetDoc">
<Referencia>
  <NroLinRef>1</NroLinRef>
  <TpoDocRef>802</TpoDocRef>
  <FolioRef>25800-220-POAMPCG</FolioRef>
  <FchRef>2021-09-30</FchRef>
  <RazonRef>25800-220- POA-MPCG00001</RazonRef>
</Referencia>
<Referencia>
  <NroLinRef>2</NroLinRef>
  <TpoDocRef>803</TpoDocRef>
  <FolioRef>EDP 03</FolioRef>
  <FchRef>2021-09-30</FchRef>
  <RazonRef />
</Referencia>
<Referencia>
  <NroLinRef>3</NroLinRef>
  <TpoDocRef>801</TpoDocRef>
  <FolioRef>176644799</FolioRef>
  <FchRef>2021-09-30</FchRef>
  <RazonRef />
</Referencia>
....bla bla bla 

I need to get the tag text "FolioRef" only when the another tag "TpoDocRef" is equal to "801" when i get it i need to store it and put inside a td like this, this is what i got so far, but it doesnt show up when i create the pdf

<td style="font-size:12px;border-left:2px solid black">                         
         <xsl:value-of select="sii:EnvioDTE/sii:*/sii:DTE/sii:Documento/sii:Referencia[TpoDocRef='801']/sii:FolioRef"/>
    </td>

At the end i should be able to get "176644799"

Thanks in advance

Got the answer, the problem was with the namespace, when i try to get the node in the [], it should has the namespace aswell like this

<xsl:value-of select="sii:EnvioDTE/sii:*/sii:DTE/sii:Documento/sii:Referencia[sii:TpoDocRef='801']/sii:FolioRef"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM