在WPF中将HTML解析为XAML时遇到问题

本文关键字:XAML 遇到 问题 WPF 中将 HTML | 更新日期: 2023-09-27 18:26:25

我使用的是WPF富编辑器库开源控件。我从那里得到的http://wpfricheditorlibrary.codeplex.com/

该控件的XML解析器缺少<Table.Columns>打开和关闭属性,这对于在xaml中创建表是非常必要的。

所需的解析输出应该是:

 <FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
            <Section FontFamily="tahoma" FontSize="11px"><Paragraph><LineBreak /></Paragraph>
                <Table>
                    **<Table.Columns>**
                    <TableColumn Width="100" />
                    <TableColumn Width="100" />
                    <TableColumn Width="100" />
                    <TableColumn Width="100" />
                    <TableColumn Width="100" />
                        **</Table.Columns>**
                    <TableRowGroup>
                        <TableRow>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                        </TableRow>
                        <TableRow>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                        </TableRow>
                    </TableRowGroup>
                </Table>
                <Paragraph>
                    <LineBreak />
                </Paragraph>
            </Section>
        </FlowDocument>

但是xml解析器返回的不包括<Table.Columns>标签:

  <FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
            <Section FontFamily="tahoma" FontSize="11px"><Paragraph><LineBreak /></Paragraph>
                <Table>
                    <TableColumn Width="100" />
                    <TableColumn Width="100" />
                    <TableColumn Width="100" />
                    <TableColumn Width="100" />
                    <TableColumn Width="100" />
                    <TableRowGroup>
                        <TableRow>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                        </TableRow>
                        <TableRow>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                            <TableCell BorderThickness="1,1,1,1" BorderBrush="Black" ColumnSpan="1"><Paragraph><LineBreak /></Paragraph></TableCell>
                        </TableRow>
                    </TableRowGroup>
                </Table>
                <Paragraph>
                    <LineBreak />
                </Paragraph>
            </Section>
        </FlowDocument>

请建议我该怎么办?

在WPF中将HTML解析为XAML时遇到问题

我认为这是解析器中的一个错误。我提交了一个问题:https://wpfricheditorlibrary.codeplex.com/workitem/8936