2016-06-03 3 views
-2

Ich habe XAML-Daten von einem Rich-Text-Editor. Die Informationen, die ich in XAML habe, sind HTML-Tags und ihre zugehörigen Attribute. Wie Absatz, seinen Text, Stil, etc. Ich möchte es in HTML konvertieren. Ein Teil von XAML:XAML in HTML konvertieren

<t:RadDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:t="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents" xmlns:s="clr-namespace:Telerik.Windows.Documents.Model.Styles;assembly=Telerik.Windows.Documents" version="1.2" LayoutMode="Flow" LineSpacing="1.15" LineSpacingType="Auto" ParagraphDefaultSpacingAfter="12" ParagraphDefaultSpacingBefore="0" SectionDefaultPageSize="816,1056" StyleName="defaultDocumentStyle"> 
    <t:RadDocument.ProtectionSettings> 
<t:DocumentProtectionSettings EnableDocumentProtection="False" Enforce="False" HashingAlgorithm="None" HashingSpinCount="0" ProtectionMode="ReadOnly" /> 
    </t:RadDocument.ProtectionSettings> 
    <t:RadDocument.Styles> 
    <s:StyleDefinition DisplayName="Document Default Style" IsCustom="False" IsDefault="False" IsPrimary="True" Name="defaultDocumentStyle" Type="Default"> 
     <s:StyleDefinition.ParagraphStyle> 
     <s:ParagraphProperties LineSpacing="1.15" SpacingAfter="12" /> 
     </s:StyleDefinition.ParagraphStyle> 
     <s:StyleDefinition.SpanStyle> 
     <s:SpanProperties FontFamily="Verdana" FontSize="16" FontStyle="Normal" FontWeight="Normal" /> 
     </s:StyleDefinition.SpanStyle> 
    </s:StyleDefinition> 
    <s:StyleDefinition DisplayName="TableNormal" IsCustom="False" IsDefault="True" IsPrimary="True" Name="TableNormal" Type="Table" /> 
    </t:RadDocument.Styles> 
    <t:Section> 
    <t:Paragraph Background="#00FFFFFF" FirstLineIndent="0" LeftIndent="0" LineSpacing="1.14999997615814" LineSpacingType="Auto" RightIndent="0" SpacingAfter="0" SpacingBefore="0" TextAlignment="Center"> 
     <t:Span FontWeight="Bold" Text="PATIENT REPORT" UnderlineDecoration="Line" /> 
    </t:Paragraph> 
    </t:Section> 
</t:RadDocument> 

Wie kann ich dies in HTML konvertieren?

+0

die gleiche Art, wie wir Äpfel umwandeln in Orangen. Es macht keinen Sinn. – Slyvain

+0

Wahr. Aber die Informationen, die ich in XAML habe, sind HTML-Tags und ihre zugehörigen Attribute. Wie Absatz, seinen Text, Stil, etc. Bitte helfen. – eysharma

Antwort

0

Also was Sie dort haben, ist ein RadDocument.

Sie können dies leicht umwandeln mit den Telerik Werkzeuge in HTML:

public string ConvertToHtml(RadDocument doc) 
{ 
    return new HtmlFormatProvider().Export(doc); 
} 

Alternativ, wenn Ihr XAML als String existiert können Sie dies tun:

public string ConvertXamlToHtml(string xamlString) 
{ 
    return new HtmlFormatProvider().Export(new XamlFormatProvider().Import(xamlString)); 
} 
+0

Danke, ich habe diesen Ansatz benutzt und es hat funktioniert. – eysharma