Ich habe die xml folgendenKonvertieren bestimmtes Attribut Wert in Xml
<CommPaid>
<CommPaidData>
<CommPaidData>
<ChangeType>-1</ChangeType>
<CoreMessageObjectArray>
<HasMessage>False</HasMessage>
<Message/>
<MessageCode/>
<Severity>0</Severity>
</CoreMessageObjectArray>
<ID>f4dc3b81-37f3-4789-a4a1-934bc39c6817</ID>
<PremSource>EC</PremSource>
<BatchControlNumber/>
<PolRefNumb>Test_ram</PolRefNumb>
<PremPaidDate>2015-12-11T00:00:00.0000000</PremPaidDate>
<TotPremPayment>100000</TotPremPayment>
<CommPrem>100000</CommPrem>
<TransactionType id="00000000-0000-0000-0000-000000000001" code="1YRL">1ST YR LIFE</TransactionType>
<PremiumType id="00000000-0000-0000-0000-000000000001" code="REG">Regular</PremiumType>
<PremAmount>100000</PremAmount>
<CommAgtLevel>Level 1</CommAgtLevel>
<CommAgtValidation/>
<WritingAgtCode>T127698</WritingAgtCode>
<WritingAgtLevel>Level 1</WritingAgtLevel>
<AgtMaxPct>0.05</AgtMaxPct>
<AgtShare>1</AgtShare>
<AgtMaxCommAvail>5000</AgtMaxCommAvail>
<AgtNetPct>0.05</AgtNetPct>
<AgtNetComm>5000</AgtNetComm>
<AdjustType>Commission Earned</AdjustType>
<CommPayStatus id="ffffffff-ffff-ffff-ffff-ffffffffffff" code="" />
<EffectiveDate>2015-12-11T00:00:00.0000000</EffectiveDate>
<LOB id="00000000-0000-0000-0000-000000000001" code="F">Flexible Premium Annuity</LOB>
<TrxDescription/>
<PlanCode>e6be3d0c-355a-4cbd-a38d-64aeab063c7f</PlanCode>
<PlanDesc>e6be3d0c-355a-4cbd-a38d-64aeab063c7f</PlanDesc>
<AgentNumber>T127698</AgentNumber>
<CommStatementID>7a11aab1-2ec2-43c8-b131-af675c4c8149</CommStatementID>
<PolicyYear>1</PolicyYear>
<PremiumMode/>
<IssueState>00000000-0000-0000-0000-000000000035</IssueState>
<CommRateAdj>0</CommRateAdj>
<EntityStatus id="0">False</EntityStatus>
<DisplayFieldName/>
<UserID>00000000-0000-0000-0000-000000000019</UserID>
<TimeStamp>2015-12-11T11:06:17.8370000</TimeStamp>
</CommPaidData>
</CommPaidData>
</CommPaid>
Es gibt bestimmten Knoten in der XML, das Attribut "Code" hat. Ich möchte das Attribut entfernen und als Wert in der XML hinzufügen, und ich möchte auch
zum Beispiel
<LOB id="00000000-0000-0000-0000-000000000001" code="F">Flexible Premium Annuity</LOB>
alle anderen Attribute aus der XML entfernen sollte es
<LOB>F</LOB>
Dies mag sollte für alle Knoten passieren, die Attribut-ID und Code haben.
Bis jetzt habe ich ein xslt erstellt, aber es funktioniert nicht richtig. Die Xslt ist: -
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<xsl:element name="{name()}"><xsl:value-of select="."/></xsl:element>
</xsl:template>
</xsl:stylesheet>
Dies ergibt eine Ausgabe wie
<LOB>
<id>00000000-0000-0000-0000-000000000001</id>
<code>F</code>
Flexible Premium Annuity
</LOB>
Könnte mir jemand eine Anleitung mit Xslt bieten, ich bin auch offen für einen C# -Code zu schreiben.