将Excel导出到XML时如何设置标签ID? [英] How to set a tag ID when exporting Excel to XML?
问题描述
我有一个非常简单的三列excel文件:
I have a very simple, three-column excel file:
我想将其导出为具有以下结构的XML文件:
I would like to export it to an XML file with the following structure:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<translations>
<item id="USER_NAME">
<en>Username</en>
<de>Username_D</de>
</item>
<item id="PASSWORD">
<en>Password</en>
<de>Password_D</de>
</item>
</translations>
到目前为止,我只设法使用以下映射文件
I only managed to use the following mapping file so far
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="translations">
<xs:complexType>
<xs:sequence>
<xs:element ref="item" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="item" id="pippo">
<xs:complexType>
<xs:sequence>
<xs:element name="en" type="xs:string"/>
<xs:element name="de" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
几乎给出了我想要的东西:
Which almost gives what I want:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<translations>
<item>
<en>Username</en>
<de>Username_D</de>
</item>
<item>
<en>Password</en>
<de>Password_D</de>
</item>
</translations>
如何将id字段设置为idem节点?
How do I set the id field into the idem node?
推荐答案
OK,我找到了一个解决方法。
OK, I found a workaround.
我创建了一个这样的XML(即类似于最终结果)
I create an XML like this (i.e. resembling the final result)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<translations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<item id="USER_NAME">
<en>Username</en>
<de>Username_D</de>
</item>
<item id="PASSWORD">
<en>Password</en>
<de>Password_D</de>
</item>
</translations>
通过开发人员选项卡将XML导入Excel。
将其拖动到新的电子表格,以便我有一个新的基于XML的Excel工作表。
复制/粘贴我需要和导出的所有值。
所以,例如,这张表
Import the XML into Excel via the Developer tab. Drag it to a new spreadsheet so that I have a new XML-based Excel sheet. Copy/paste all the values I need and export. So, for example, this sheet
将生成此XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<translations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<item id="USER_NAME">
<en>Username</en>
<de>Username_D</de>
</item>
<item id="PASSWORD">
<en>Password</en>
<de>Password_D</de>
</item>
<item id="SOME">
<en>A</en>
<de>B</de>
</item>
</translations>
这篇关于将Excel导出到XML时如何设置标签ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!