Excel XML 导出的 XML 架构
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8374958/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XML schema for Excel XML exportation
提问by Nicolaesse
I'm getting mad trying to create an XML schema to transform an Excel file to an XML file. The sample .xls file has two cell with
试图创建一个 XML 模式以将 Excel 文件转换为 XML 文件时,我很生气。示例 .xls 文件有两个单元格
- the name of the event and
- the name of the location then there's a table with a session for every column and a rider's name for every row.
- 事件的名称和
- 位置的名称然后有一个表格,每一列都有一个会话,每一行都有一个骑手的名字。
This is a screenshot of the spreadsheet.
To save as XML data I need to make the XML schema and I've achived this using the Excel 2003 Add-in: XML Tools Add-in. So I have this XML schema:
要保存为 XML 数据,我需要创建 XML 架构,并且我已经使用Excel 2003 Add-in: XML Tools Add-in 实现了这一点。所以我有这个 XML 模式:
<?xml version='1.0' encoding='UTF-16'?>
<!-- Created from XmlMap.Name: Results_mapping -->
<!-- XmlMap.DataBinding.SourceUrl: -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element nillable="true" name="Results">
<xsd:complexType>
<xsd:sequence minOccurs="0">
<xsd:element minOccurs="0" maxOccurs="unbounded" nillable="true" name="rider" form="unqualified">
<xsd:complexType>
<xsd:sequence minOccurs="0">
<xsd:element minOccurs="0" nillable="true" type="xsd:string" name="Column1" form="unqualified"/>
<xsd:element minOccurs="0" nillable="true" type="xsd:integer" name="Column_1st_session" form="unqualified"/>
<xsd:element minOccurs="0" nillable="true" type="xsd:integer" name="Column_2nd_session" form="unqualified"/>
<xsd:element minOccurs="0" nillable="true" type="xsd:integer" name="Column_3rd_session" form="unqualified"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
which generate the following XML code:
生成以下 XML 代码:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<rider>
<Column1>Mike</Column1>
<Column_1st_session>5</Column_1st_session>
<Column_2nd_session>10</Column_2nd_session>
<Column_3rd_session>8</Column_3rd_session>
</rider>
<rider>
<Column1>John</Column1>
<Column_1st_session>5</Column_1st_session>
<Column_2nd_session>9</Column_2nd_session>
<Column_3rd_session>8</Column_3rd_session>
</rider>
<rider>
<Column1>Lea</Column1>
<Column_1st_session>4</Column_1st_session>
<Column_2nd_session>9</Column_2nd_session>
<Column_3rd_session>8</Column_3rd_session>
</rider>
</Results>
That's not completely bad but I'd like to have something like
这并不完全糟糕,但我想要一些类似的东西
<rider name="Mike">
<session name="1st_session">5</session>
<session name="2nd_session">10</session>
<session name="3rd_session">8</session>
</rider>
can anybody please help me? Thanks!
有人可以帮我吗?谢谢!
采纳答案by Nicolaesse
After many tutorials and manuals I've found a really useful guide about how to make the mapping of the *xls file automatically and without plug-in...very good! http://www.mrexcel.com/articles/using-xml-in-excel.php
在阅读了许多教程和手册之后,我找到了一个非常有用的指南,该指南关于如何在没有插件的情况下自动制作 *xls 文件的映射......非常好!http://www.mrexcel.com/articles/using-xml-in-excel.php

