%% Transform XML and Return Result as a String
% This example transforms the XML markup for countries and their capital cities into an HTML table and returns the resulting HTML as a string scalar.
% The examples use these files:
% capitals.xml
% <Countries>
%     <Country><Name>Canada</Name><Capital>Ottawa</Capital></Country>
%     <Country><Name>France</Name><Capital>Paris</Capital></Country>
%     <Country><Name>Peru</Name><Capital>Lima</Capital></Country>
% </Countries>
% capitals.xsl
% <?xml version="1.0"?>
%
% <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
%
% <xsl:template match="/">
%   <html>
%   <body>
%       <table>
%       <tr>
%         <th>Country</th>
%         <th>Capital</th>
%       </tr>
%       <xsl:for-each select="Countries/Country">
%         <tr>
%           <td><xsl:value-of select="Name"/></td>
%           <td><xsl:value-of select="Capital"/></td>
%         </tr>
%       </xsl:for-each>
%     </table>
%   </body>
%   </html>
% </xsl:template>
%
% </xsl:stylesheet>
% Use the transformToString method to transform the XML in capitals.xml to an HTML string. Specify that the stylesheet is capitals.xsl.

import matlab.io.xml.transform.*
result = transformToString(Transformer,"capitals.xml","capitals.xsl");

% Display the resulting HTML string.

result

%
% Copyright 2020 The MathWorks, Inc.