我正在使用XSL和XPATH遍歷,讀取和轉換複雜的XML文件,其中具有多個名稱相同但值不同的節點。我的示例XML文件低於 -使用xpath和xsl遍歷xml文檔
<core>
<address>
<postalZipCode>90017</postalZipCode>
<updateSource>xxxxxx</updateSource>
<city>LOS ANGELES</city>
<stateProvince>CA</stateProvince>
<type>MAILING</type>
<line1>818 WEST SEVENTH STREET</line1>
</address>
<address>
<postalZipCode>95014</postalZipCode>
<updateSource>xxxxxx</updateSource>
<city>CUPERTINO</city>
<stateProvince>CA</stateProvince>
<type>PRIMARY</type>
<line1>1234 XYZ STREET</line1>
</address>
<memberId>0</memberId>
</core>
當我讀的郵件地址線1的值,我得到的值是「1234 XYZ STREET」基本上是主地址。這是我的XSL文件片段: -
<xsl:template match="core">
<xsl:if test="memberId['0'] and address/type['MAILING']">
<fo:table-row>
<fo:table-cell><fo:block /></fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="data">
<fo:block>Line 1</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="data">
<fo:block><xsl:value-of select="address/line1/text()"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
可以在這裏的高手請建議如果有可能的任何其他方式強制XSL來讀取其中的地址是郵寄正確的值,而不是讀它找到的第一個值???
「*我得到的數值是」1234 XYZ STREET「*」不,這是**不是**值,您正在使用您在此發佈的代碼。 –