xsl从列表中检索属性值

问题描述 投票:0回答:1

我想将xml导出为另一种xml格式我有这种xml格式,但是我不知道如何检索特定的属性值

<customer customer-no="DEV04-00058013">
    <credentials>
        <login>[email protected]</login>
        <password encrypted="true" encryptionScheme="scrypt">$s0$b0401$IsYbtazLWWpFB5YgeN7TXg==$AbbSrO+0531izm83P4UGPNBXt8QiS56V8ARq5IVTfqw=</password>
        <enabled-flag>true</enabled-flag>

    </credentials>
    <profile>
        <salutation/>
        <title/>
        <first-name>Demo</first-name>
        <second-name/>
        <last-name>Xml</last-name>
        <suffix/>
        <company-name/>
        <job-title/>
        <email>[email protected]</email>   
        <gender>1</gender>
        <custom-attributes>
            <custom-attribute attribute-id="PB_favoriteStore">002</custom-attribute>
            <custom-attribute attribute-id="CAP_EmailScoring">00002</custom-attribute>
            <custom-attribute attribute-id="PB_offersViaMail">false</custom-attribute>
            <custom-attribute attribute-id="PB_offersViaSMS">false</custom-attribute>
        </custom-attributes>
    </profile>
    <note/>
</customer>

我想知道如何检索PB_favoriteStore值。我尝试过

没有成功。感谢您的帮助

xml xls
1个回答
1
投票
我不确定您需要什么,但下面的XPath会选择attribute-id为“ PB_favoriteStore”的元素:]]

//profile/custom-attributes/custom-attribute[@attribute-id='PB_favoriteStore']

如果需要在XSL中选择值,则可以使用:
© www.soinside.com 2019 - 2024. All rights reserved.