0

Let's say I've got the following XML:

<a>
    <c>
       <d>text</d><e> more text</e>
    </c>
</a>

And I'd like to get:

<a>
    <d innerXML="&lt;d&gt;text&lt;/d&gt;&lt;e&gt; more text&lt;/e&gt;">
    </d>
</a>

How would I select the inner XML of c? The following XSLT doesn't work:

<xsl:template match="c">
   <d>
      <xsl:attribute name="innerXML">
         <xsl:copy-of select="."/>
      </xsl:attribute>
   </d>
</xsl:template>

P.S. Please note that this is an extremely simplified version of what I'm try

user2950509
  • 1,018
  • 2
  • 14
  • 37
  • have a look at this http://stackoverflow.com/questions/6696382/xslt-how-to-convert-xml-node-to-string – Nateous Apr 04 '17 at 14:31
  • 2
    You want to serialize the sub-tree; this feature is available in XSLT 3.0 (and in some XSLT 2.0 processors as an extension). Doing this natively in XSLT 1.0 or 2.0 is very awkward and error-prone. – michael.hor257k Apr 04 '17 at 14:34
  • Can you use a programming language like c# for this goal? – Alexander Petrov Apr 04 '17 at 16:09

0 Answers0