我在尝试创建XML模式以将Excel文件转换为XML文件时感到很生气。 示例.xls文件有两个带
的单元格This is a screenshot of the spreadsheet.
要保存为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>
生成以下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>
这不是很糟糕,但我想要像
这样的东西<rider name="Mike">
<session name="1st_session">5</session>
<session name="2nd_session">10</session>
<session name="3rd_session">8</session>
</rider>
有人可以帮帮我吗?
谢谢!
答案 0 :(得分:3)
经过许多教程和手册后,我发现了一个非常有用的指南,介绍了如何自动映射* xls文件而没有插件......非常好! http://www.mrexcel.com/articles/using-xml-in-excel.php