计算C#中的XML模式元素 [英] Counting XML Schema Elements in C#

查看:127
本文介绍了计算C#中的XML模式元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要导入数据库的XML文件,但是,我需要确保用户选择了适当的目标数据库.

反过来,我正在计算目标表的列:

I have a XML file that I am importing into a database, however, I need to ensure that the user has selected an appropriate target database.

In turn, I am counting the target table''s columns:

SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'SOME_TABLE'



并将其与XML模式中声明的元素计数进行比较.但是,我无法弄清楚如何计算架构的< xs:element>''.

这是一个示例:



and comparing it to the count of elements declared in the XML schema. However, I cannot figure out how to count the <xs:element>''s of the schema.

Here is an example:

<xs:element id="list" name="list">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:annotated">
<xs:sequence>
<xs:element minOccurs="0" name="simpleType" 

<xs:element ...>
<xs:element ...>
type="xs:localSimpleType"/>
</xs:sequence>
<xs:attribute name="itemType" type="xs:QName" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>


任何帮助将不胜感激(示例甚至更好)!
谢谢


Any help would be appreciated (examples are even better)!
Thanks

推荐答案

看看这些链接,这些应该可以帮助您指出正确的方向.

遍历XML架构 [管理XML模式文件(添加元素-属性) [
Have a look at these links thay should help to point you in the right direction.

Traversing XML Schemas[^]
Manage XML Schema File ( add element - Attribute)[^]


这篇关于计算C#中的XML模式元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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