首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Excel列表上生成XML映射?

如何在Excel列表上生成XML映射?
EN

Stack Overflow用户
提问于 2019-05-07 17:03:27
回答 1查看 368关注 0票数 0

主要用途:我有一个给定的XML文件和Excel中的客户名列表。我想创建一个XML映射,这样我就可以用它生成一个新的XML文件。

我的问题是: Excel不映射整个列表(列),而只映射单个单元格。

这是我的XML文件:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Profiles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/Users/baj426/Documents/Altova/XMLSpy2018/Examples/test.xsd">
    <Profile CompanyId="" Duns="">
        <Tab name="Tab_Address" label="Address">
            <Group Name="Group_IDs">
                <Field Value="true" Name="Field_IDs_SIM_Strategic"/>
            </Group>
        </Tab>
    </Profile>
</Profiles>

这是由XMLSPy生成的我的XML-Schema:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?>

<!-- W3C Schema generated by XMLSpy v2018 rel. 2 (x64) (http://www.altova.com) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Tab">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Group"/>
            </xs:sequence>
            <xs:attribute name="name" use="required">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="Tab_Address"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="label" use="required">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="Address"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
    </xs:element>
    <xs:element name="Field">
        <xs:complexType>
            <xs:attribute name="Value" use="required" type="xs:boolean"/>
            <xs:attribute name="Name" use="required">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="Field_IDs_SIM_Strategic"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
    </xs:element>
    <xs:element name="Group">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Field"/>
            </xs:sequence>
            <xs:attribute name="Name" use="required">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="Group_IDs"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
    </xs:element>
    <xs:element name="Profile">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Tab"/>
            </xs:sequence>
            <xs:attribute name="CompanyId" use="required">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value=""/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="Duns" use="required">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value=""/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
    </xs:element>
    <xs:element name="Profiles">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Profile"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

这是我想要的示例代码:

下面是XSD示例:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?>

<shiporder orderid="889923"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="shiporder.xsd">
  <orderperson>John Smith</orderperson>
  <shipto>
    <name>Ola Nordmann</name>
    <address>Langgt 23</address>
    <city>4000 Stavanger</city>
    <country>Norway</country>
  </shipto>
  <item>
    <title>Empire Burlesque</title>
    <note>Special Edition</note>
    <quantity>1</quantity>
    <price>10.90</price>
  </item>
  <item>
    <title>Hide your heart</title>
    <quantity>1</quantity>
    <price>9.90</price>
  </item>
</shiporder> 

XML-与Excel中的某些值映射后的文件

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<shiporder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <item>
        <quantity>1</quantity>
        <price>120</price>
    </item>
    <item>
        <quantity>2</quantity>
        <price>120</price>
    </item>
    <item>
        <quantity>3</quantity>
        <price>120</price>
    </item>
    <item>
        <quantity>4</quantity>
        <price>120</price>
    </item>
    <item>
        <quantity>5</quantity>
        <price>120</price>
    </item>
    <item>
        <quantity>6</quantity>
        <price>120</price>
    </item>
    <item>
        <quantity>7</quantity>
        <price>120</price>
    </item>
    <item>
        <quantity>8</quantity>
        <price>120</price>
    </item>
</shiporder>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56019078

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档