关于XAML代码的解析

bk7477890 2010-10-15 09:48:12
各位好

现有需求将RichTextbox的XAML属性产生的XAML代码转换为HTML代码

想听听各位有什么好的意见。


<Section xml:space="preserve" HasTrailingParagraphBreakOnPaste="False" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left"><Run FontSize="14" FontFamily="Courier New" Foreground="#FF000000" FontWeight="Bold" FontStyle="Italic" FontStretch="Normal" Text="ceshishuju_测试数据" /></Paragraph><Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left"><Run FontSize="14" FontFamily="Comic Sans MS" Foreground="#FF000000" FontWeight="Bold" FontStyle="Italic" FontStretch="Normal" Text="ceshishuju_测试数据" /></Paragraph><Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left"><Run FontSize="14" FontFamily="Courier New" Foreground="#FF0000FF" FontWeight="Normal" FontStyle="Italic" FontStretch="Normal" Text="ceshishuju_测试数据" /></Paragraph><Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left"><Run FontSize="14" FontFamily="Courier New" Foreground="#FFFF0000" FontWeight="Bold" FontStyle="Normal" FontStretch="Normal" Text="ceshishuju_测试数据" /></Paragraph><Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left"><Run FontSize="14" FontFamily="Arial" Foreground="#FF000000" FontWeight="Bold" FontStyle="Italic" FontStretch="Normal" Text="ceshishuju_测试数据" /></Paragraph><Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left"><Run FontSize="20" FontFamily="Courier New" Foreground="#FF000000" FontWeight="Bold" FontStyle="Italic" FontStretch="Normal" Text="ceshishuju_测试数据" /></Paragraph></Section>


例如这样的代码

转换成HTML


...全文
56 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bryht 2011-03-18
  • 打赏
  • 举报
回复
MSDN WPF XAML与HTML互换
bk7477890 2010-10-15
  • 打赏
  • 举报
回复
<Section xml:space="preserve" HasTrailingParagraphBreakOnPaste="False" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run FontSize="14" FontFamily="Courier New" Foreground="#FF000000" FontWeight="Bold" FontStyle="Italic" FontStretch="Normal" Text="ceshishuju_测试数据" />
</Paragraph>
<Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run FontSize="14" FontFamily="Comic Sans MS" Foreground="#FF000000" FontWeight="Bold" FontStyle="Italic" FontStretch="Normal" Text="ceshishuju_测试数据" />
</Paragraph>
<Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run FontSize="14" FontFamily="Courier New" Foreground="#FF0000FF" FontWeight="Normal" FontStyle="Italic" FontStretch="Normal" Text="ceshishuju_测试数据" />
</Paragraph>
<Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run FontSize="14" FontFamily="Courier New" Foreground="#FFFF0000" FontWeight="Bold" FontStyle="Normal" FontStretch="Normal" Text="ceshishuju_测试数据" />
</Paragraph>
<Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run FontSize="14" FontFamily="Arial" Foreground="#FF000000" FontWeight="Bold" FontStyle="Italic" FontStretch="Normal" Text="ceshishuju_测试数据" />
</Paragraph>
<Paragraph FontSize="20" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run FontSize="20" FontFamily="Courier New" Foreground="#FF000000" FontWeight="Bold" FontStyle="Italic" FontStretch="Normal" Text="ceshishuju_测试数据" />
</Paragraph>
</Section>

我换了一下行,这样看起来比较方便

17,748

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧