第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在循環(huán)中將 CDATA 添加到節(jié)點值

在循環(huán)中將 CDATA 添加到節(jié)點值

C#
米琪卡哇伊 2022-06-12 15:16:07
我正在嘗試將 <![CDATA[...]] 添加到循環(huán)內(nèi)生成的值節(jié)點。我正在使用 XSLT 和 C#.net。我已經(jīng)嘗試了幾件事,包括 將 CDATA 添加到 xml 文件 ,但到目前為止似乎沒有任何工作。我什至嘗試按字面意思添加它,但正如預(yù)期的那樣,它沒有成功。任何人都可以在這方面幫助我。這是我的節(jié)點的生成方式<xsl:for-each select="$OLifE/">                    <DataPoint>                      <Name>Carrier.Requirements<xsl:if test="$NumberOfPayments > 1"><xsl:value-of select="position()"/></xsl:if></Name>                      <Value>Here is the response text</Value></DataPoint>我的預(yù)期輸出是<DataPoint>    <Name>Carrier.Requirements1</Name>    <Value><![CDATA[Here is the response text]]</Value></DataPoint><DataPoint>    <Name>Carrier.Requirements2</Name>    <Value><![CDATA[Here is the response text]]</Value></DataPoint><DataPoint>    <Name>Carrier.Requirements3</Name>    <Value><![CDATA[Here is the response text]]</Value></DataPoint>如果需要任何進一步的信息,請告訴我。
查看完整描述

1 回答

?
溫溫醬

TA貢獻1752條經(jīng)驗 獲得超4個贊

這是一個簡化的示例:


XML


<input>

    <item/>

    <item/>

    <item/>

</input>

XSLT 1.0


<xsl:stylesheet version="1.0" 

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" cdata-section-elements="Value"/>

<xsl:strip-space elements="*"/>


<xsl:template match="/input">

    <output>

        <xsl:for-each select="item">

            <DataPoint>

                <Name>

                    <xsl:value-of select="concat('Carrier.Requirements', position())"/>

                </Name>

                <Value>Here is the response text</Value>

            </DataPoint>

        </xsl:for-each>

    </output>

</xsl:template>


</xsl:stylesheet>

結(jié)果


<?xml version="1.0" encoding="utf-16"?>

<output>

  <DataPoint>

    <Name>Carrier.Requirements1</Name>

    <Value><![CDATA[Here is the response text]]></Value>

  </DataPoint>

  <DataPoint>

    <Name>Carrier.Requirements2</Name>

    <Value><![CDATA[Here is the response text]]></Value>

  </DataPoint>

  <DataPoint>

    <Name>Carrier.Requirements3</Name>

    <Value><![CDATA[Here is the response text]]></Value>

  </DataPoint>

</output>

演示:https ://xsltfiddle.liberty-development.net/94hvTAn


查看完整回答
反對 回復(fù) 2022-06-12
  • 1 回答
  • 0 關(guān)注
  • 180 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號