[英]Get text value of node based on another node text in xslt
我有一個具有以下示例格式的 xml
<?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
只有當另一個標簽“TpoDocRef”等於“801”時,我才需要獲取標簽文本“FolioRef”,當我得到它時,我需要存儲它並像這樣放入 td,這是我到目前為止所得到的,但是當我創建 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>
最后我應該能夠得到“176644799”
提前致謝
得到了答案,問題出在命名空間上,當我嘗試在 [] 中獲取節點時,它也應該具有這樣的命名空間
<xsl:value-of select="sii:EnvioDTE/sii:*/sii:DTE/sii:Documento/sii:Referencia[sii:TpoDocRef='801']/sii:FolioRef"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.