In a asp.net Web Application
I have four arrays/lists (client side). It is some sort of metadata for rendering nested headers on top of the gridview.
- header: This list contains all the header names (labels) like Name, Organisation. At the same index the list two contains the parent of this header if it is to be nested inside some other header. If not then at the same index list two will have null.
- headerParent: This list contains the id of the one of the items in first list.
- column: This list contains the name of the actual data column names. At the same index in fourth list it contains the name of the header under which this column should appear.
- columnParent: This list contains the id of the one of the items in first list.
I want to read all these lists and turn them into some sort of nested XML (on server side), which I can then easily read or parse using xsl. Basically I'm struggling with some sort of basic algorithm how to process these lists. I am looking for output similar to the one below.
<?xml version="1.0" encoding="utf-8" ?>
<Header name="Table">
<Header name="Number">
<Column name="OrgRef"></Column>
<Column name="OrgTypeId"></Column>
</Header>
<Header name="String">
<Column name="DisplayName"></Column>
</Header>
<Column name="OrgCode"></Column>
</Header>
I am also open to the idea of storing this information some other way than storing it into four lists in first place. As user will be doing it on a website, so my options are limited. At the moment I'm doing it using javascript and persisting this information in html control and reading at server side to process it further.