解析 xml 并将格式应用于文本
我正在 XML 文件中存储一些文本,并希望通过将格式应用于 RichTextBox 或类似内容中的文本来在我的应用程序中显示它(也许将其作为列表框也更好?),
它会是这样的这个
<Text>
<Normal> This is some <Bold> text </Bold> which i like to put somewhere </Normal>
<Bold><Italic> But there is a problem </Italic></Bold>
<Normal> I don't know how </Normal>
</Text>
文本看起来像这样
这是一些我喜欢放在某处的文本 但是有一个问题 我不知道
我是如何在网上搜索的,但没有找到任何解决方案...
编辑:我忘了说我正在开发一个 silverlight 导航应用程序,所以我无法使用 flowdocuments:/
I am storing some text in a XML file and want to display it in my application by applying the formating to the text in a RichTextBox or something similar (maybe it would be better to have it as a listbox too?)
it would be something like this
<Text>
<Normal> This is some <Bold> text </Bold> which i like to put somewhere </Normal>
<Bold><Italic> But there is a problem </Italic></Bold>
<Normal> I don't know how </Normal>
</Text>
this text would look like this
This is some text which i like to put somewhere
But there is a problem
I don't know how
I have searched the net but didnt find any solution...
Edit: I forgot to say that I am developing a silverlight navigation application so i cant user flowdocuments:/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须手动检查 XML 节点并定义每个节点应该发生的情况。有很多不同的方法可以实现类似的功能,但我首先会保持简单。
例如:(伪代码)
你可以这样做,相当简单。我确信有很多方法可以改进它,而且我确信它会变得相当复杂。
You'd have to manually go through the XML nodes and define what should happen for each node. There's many different ways to implement something like that, but I'd start by keeping it simple.
For example: (pseudocode)
You can do it like this, which is fairly simple. I'm sure there is many ways to improve upon it and it can get fairly complicated I'm sure.