XSD and data in excel file - Need to use Aspose to create XML

I have the following XSD

<xs:schema xmlns:xs=“http://www.w3.org/2001/XMLSchema”>
<xs:element name=“Document”>
xs:complexType
xs:sequence
<xs:element name=“ActorFirstName” type=“xs:string” minOccurs=“1” maxOccurs=“1”>
xs:annotation
xs:appinfoDisplayName:First Name</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name=“ActorMiddleName” type=“xs:string” minOccurs=“0” maxOccurs=“1”>
xs:annotation
xs:appinfoDisplayName:Middle Name</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name=“ActorLastName” type=“xs:string” minOccurs=“1” maxOccurs=“1”>
xs:annotation
xs:appinfoDisplayName:Last Name</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name=“AgentCompanyName” type=“xs:string” minOccurs=“0” maxOccurs=“1”>
xs:annotation
xs:appinfoDisplayName:Company Name</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

In Actor Data excel file .xslx, I have the following.

ActorFirstName ActorMiddleName ActorLastName AgentCompanyName
George Mighty Cool LAWide
Jason David Batman QAWilde
Brad O Cricketer LV Studios

Based on the XSD, I want to generate One xml record per row.

How can this be achieved using aspose.cells?

Note:
The generated xml will be passed as a parameter to a third-party webservice which in-turn saves the record to the database.

@DotnetUser23

Do you want to achieve this using back-end .NET Aspose.Cells API?

Yes wanted to use .net Aspose.cells API. Excel will contain rows of data, based on the XSD, my requirement is to generate xml file per row.

@DotnetUser23,

Generally, Aspose.Cells follows MS Excel standards and specifications. How could you generate your desired XML file in MS Excel manually, please elaborate with steps details? Also, please give your input files and your desired output XML file(s). We will check it soon.

PS. please zip the files prior attaching here.

Manually, I tried - Developer menu import xml and specify the xsd file. The right click and map element. Then click export button. However I am able to only get the row that I map and not all the rows. I am able to generate 1 xml file but I need 3 xml files (one per row)

Please find attached is the .zip file with the XSD(input), XML (1 sample output) and the excel data file. Thank you.

Excel Details.zip (9.4 KB)

@DotnetUser23,

Thanks for the files.

Please note, with Aspose.Cells API, you can can import an XmlMap or update XmlMap linked data via Workbook.ImportXml but Adding XmlMap by XSD is not supported currently. Also, Workbook.ExportXml can export an XmlMap linked data to a xml file. See the documents in the section. However, as you want to export more than one xml file (one xml file per row) we cannot meet your requirements. By the way, this feature is also not supported in Microsoft Excel either. We can log a ticket if you just need to have support xml maps by xsd (and not to have separate xml file per row), please confirm?

Sure Please log a ticket to have support xml maps by XSD. This feature is available in excel and would be great if you can support it in Aspose. Thank you.

@DotnetUser23,

We have logged a ticket with an id “CELLSNET-47951” for your issue. The ticket is logged as following:
CELLSNET-47951 - Support XML maps by XSD

Once we have an update on it, we will let you know.

@DotnetUser23

Please try the latest fix 21.3.5.
Aspose.Cells21.3.5 For .Net2_AuthenticodeSigned.Zip (5.5 MB)
Aspose.Cells21.3.5 For .Net4.0.Zip (5.5 MB)
Aspose.Cells21.3.5 For .NetStandard20.Zip (5.5 MB)

The API XmlMapCollection.Add(string url) now supports xsd file. Code:

Workbook wb = new Workbook();
XmlMapCollection maps = wb.Worksheets.XmlMaps;
maps.Add(@"Sample.xsd");

wb.Save("output.xlsx");

The issues you have found earlier (filed as CELLSNET-47951) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao