PDA

View Full Version : xml formatting into 2 columns


newdeveloper
06-21-2006, 08:03 PM
I am new to xml and need to format an xml file to be 2 equal length columns. The xml gets created at runtime and can be of varying lengths.

The format of the xml file is:
<Rows>
<Row>
<Category>Folder</Category>
<TitleIndex>0</TitleIndex>
<Title>YourTitle</Title>
<URL>YourURL.html</URL>
<ID>0</ID>
</Row>
<Row>
<Category>File</Category>
<TitleIndex>10</TitleIndex>
<Title>FileTItle</Title>
<URL>File.doc</URL>
<ID>-1</ID>
<ParentID>0</ParentID>
</Row>
..........
</Rows>

The format order should be according to TitleIndex, Title.
If the node element has a ParentID, then it should be grouped together with any node element with the corresponding ID value.
An ID value of -1 indicates that the item is a file and cannot have any nodes that use it as a parent (i.e. ParentID can never equal -1).

The difficult part is to identify the total number of rows and split them in half while not splitting any parent/child node relationships. For example, if there are 5 rows, row 1 has an ID = 1, row 2-4 all have a ParentID = 1. In this case, column 1 would need to be rows 1-4 and column 2 would need to be row 5.

Please let me know if you need any more details or if you need any clarifications.

Thanks in advance for any assistance.