Hello,
I am currently helping my BI team convert a Cognos Tree Object into a Javascript tree object. The part where I am stuck is using javascript to parse the XML data file that would normally fill up the Cognos tree.
Here is an example of the XML data file...
Also, the actual XML data file has over 40,000 lines
<?xml version="1.0" encoding="utf-8" ?>
- <dataset xmlns="http://developer.cognos.com/schemas/xmldata/1/" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
- <!--
<dataset
xmlns="http://developer.cognos.com/schemas/xmldata/1/"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://developer.cognos.com/schemas/xmldata/1/ xmldata.xsd"
>
-->
- <metadata>
<item name="ROOT_NODE_ID" type="xs:decimal" precision="38" />
<item name="LEVEL1_ID" type="xs:string" length="2002" />
<item name="LEVEL1_NAME" type="xs:string" length="512" />
<item name="LEVEL2_ID" type="xs:string" length="2002" />
<item name="LEVEL2_NAME" type="xs:string" length="512" />
<item name="LEVEL3_ID" type="xs:string" length="2002" />
<item name="LEVEL3_NAME" type="xs:string" length="512" />
<item name="LEVEL4_ID" type="xs:string" length="2002" />
<item name="LEVEL4_NAME" type="xs:string" length="512" />
<item name="LEVEL5_ID" type="xs:string" length="2002" />
<item name="LEVEL5_NAME" type="xs:string" length="512" />
<item name="LEVEL6_ID" type="xs:string" length="2002" />
<item name="LEVEL6_NAME" type="xs:string" length="512" />
<item name="LEVEL7_ID" type="xs:string" length="2002" />
<item name="LEVEL7_NAME" type="xs:string" length="512" />
<item name="LEVEL8_ID" type="xs:string" length="2002" />
<item name="LEVEL8_NAME" type="xs:string" length="512" />
<item name="LEVEL9_ID" type="xs:string" length="2002" />
<item name="LEVEL9_NAME" type="xs:string" length="512" />
<item name="LEVEL10_ID" type="xs:string" length="2002" />
<item name="LEVEL10_NAME" type="xs:string" length="512" />
</metadata>
- <data>
- <row>
<value>5</value>
<value>5</value>
<value>Global Root</value>
<value>41</value>
<value>Company</value>
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
</row>
- <row>
<value>5</value>
<value>5</value>
<value>Global Root</value>
<value>41</value>
<value>Company</value>
<value>101590</value>
<value>Customer 1</value>
<value>101591</value>
<value>Customer 1 Sites</value>
<value>125083</value>
<value>Site 1</value>
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
</row>
- <row>
<value>5</value>
<value>5</value>
<value>Global Root</value>
<value>41</value>
<value>Company</value>
<value>101590</value>
<value>Customer 1</value>
<value>101591</value>
<value>Customer 1 Sites</value>
<value>125090</value>
<value>Site 2</value>
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
</row>
</data>
</dataset>
This would link all the Level IDs and create the tree...
-Global Root
-Company
-Customer 1
-Customer 1 Sites
-Site 1
-Site 2
I have little Javascript experience and I have extensively searched the internet, but none of the examples have worked / I have not understood them.
I was wondering if anyone would be so kind to show me an example how how to parse this specific example by getting the data <row> by <row>