如何通过C#代码动态生成xml模式? [英] How to generate xml schema dynamically through c# code?

查看:137
本文介绍了如何通过C#代码动态生成xml模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想要可以动态生成xml模式的c#代码.

解决方案

所以您有一个模式,并且希望您的代码创建与该模式匹配的XML?如果您使数据成为半随机数据或来自已定义列表,那么这应该不太困难,您只需要遍历该模式,并且由于它是XML,因此可以使用DOM进行操作. /blockquote>

这有一个真正的问题.即使您编写代码以遍历给定的XML文档,它如何判断某个节点是否可选,是否只能出现一定次数等等?我相信,如果您花时间去Google,您会发现可以生成某种模式的东西,但是它仍然需要进行一些手工编辑才能完成您想要的事情.


@Christian Graus
thanx 4 ur response mate ...很抱歉,我的查询方式有误...我真正想要的是我的程序应该从架构中选择doctype并以动态方式生成xml.


Hi,
I want c# code that will generate xml schema dynamically.

解决方案

So you have a schema and you want your code to create XML that matches the schema ? If you make the data in it semi random or from a defined list, then that should not be too hard, you just need to iterate over the schema, and as it''s XML, you can use the DOM to do it.


There''s a real problem with that. Even if you write code to iterate over a given XML document, how can it tell if a certain node is optional, if it can appear only a certain number of times, etc ? I believe if you took the time to google, you could find something that generates some sort of schema, but it''s bound to still need some hand editing to do what you want it to.


@Christian Graus
thanx 4 ur response mate...sorry for putting my query in a wrong way...what i exactly want is my program should pick the doctype from the schema and will generate the xml in a dynamic manner..


这篇关于如何通过C#代码动态生成xml模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆