组织XSD文件并导出XML [英] Organize XSD file and exporting XML

查看:91
本文介绍了组织XSD文件并导出XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是WPF的新手,我正在尝试使用XML文件在XAML文件中绑定TreeView。使用你的一些帖子我设法可视化一个基本的xml文件,现在我有一个问题将我的xls文件导出到xml。



我的xls文件包含3列:id,姓名,姓氏。实际上,我有2行(这是一个例子),它们是:

- 100 Mary Smith

- 200 Clara White



我想将其导出为XML,就像:

Hi, I am quite new to WPF and I am trying to use an XML file for binding a TreeView in the XAML file. Using some of your posts I managed to visualize a basic xml file, now I have a problem to export my xls file to xml.

My xls file consists in 3 columns: id, name, surname. Actually, I have 2 rows (this is an example), they are:
- 100 Mary Smith
- 200 Clara White

I'd like to export that as an XML, just like:

<Root>
     <100> 
     <name> Mary </name>
     <surname> Smith </surname>
     </100>

     <200> 
     <name>Clara </name>
     <surname> White </surname>
     </200>
</Root>



我想写一个XSD并用它来映射xls文件,但是我不知道如何组织架构来拥有这些组。

你可以帮助我这个例子吗?



提前谢谢



我尝试了什么:



我试过这个XSD文件,但我没有在节点顶部的id值(它保持在同一级别的名称)




I'd like to write down a XSD and using it for mapping the xls file, but I don't know how organize the schema to have that groups.
Can you help me with this example?

Thanks in advance

What I have tried:

I have tried with this XSD file, but I don't have the id value on the top of the nodes (it stays on the same level of name)

<pre><?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
  <element name="Root">
		 <complexType>
			<sequence>
				<element name="identity" maxOccurs="unbounded">
					<complexType>
						<sequence>
							<element name="ID" />
							<element name="NAME"/>
						</sequence>
					</complexType>
				</element>
			</sequence>
		</complexType>
  </element>
</schema>





是否可以将ID值置于群组顶部?就像:

ID

----名称

---- SURNAME



Is it possible to bring the id value on the top of the Group? Just like:
ID
----NAME
----SURNAME

推荐答案

根据 w3schools [ ^ ],你不能只用数字来命名一个xml元素。

以下是规则:

According to w3schools[^], you cannot name a xml element with only digits.
Here are the rules:
Element names are case-sensitive
Element names must start with a letter or underscore
Element names cannot start with the letters xml (or XML, or Xml, etc)
Element names can contain letters, digits, hyphens, underscores, and periods
Element names cannot contain spaces



所以,不,这是不可能的以您向我们呈现它的方式定义模式(因为它意味着定义一个名称仅由数字组成的元素)。此外,您似乎将元素的名称( id )与其值( 100 ,<$ c $)混淆c> 200 ,等等。)

你最好创建一个记录元素(例如),有三个其中的元素: id name surname 。您还可以将这些元素作为记录元素的属性,因为它们都是简单的整数和字符串值。但这是个人偏好的问题。

希望这会有所帮助。


So, no, it is not possible to define a schema the way you presented it to us (because it would mean defining an element whose name is composed only of digits). Moreover, you seem to confound the name of the element (id) with its value (100, 200, etc.).
You would better create a record element (for example), having three elements in it: id, name, surname. You can also make these elements as attributes of the record element, since they all are simple integer and string values. But that's a matter of personal preference.
Hope this helps.


这篇关于组织XSD文件并导出XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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