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
- 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 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 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!