Hi Everyone,
I have the following xml from which I need a particular output .
<items>
<item id="film">
<category>entertainment </category>
<category>drama</category>
<category>music </category>
</item>
<item id="sitcom">
<category>entertainment </category>
<category>tv</category>
</item>
</items>
Output I would like
film|entertainment
film|drama
film|music
sitcom|entertainment
sitcom|tv
But the code I have displays the output as
film|entertainment
film|drama
film|music
film|entertainment
film|tv
sitcom|entertainment
sitcom|drama
sitcom|music
sitcom|entertainment
sitcom|tv
And this is the code I have
static void GetItem(Document doc){
Element root = doc.getDocumentElement();
Element[] items = getElementsByTagNameNR(root,"Item");
for(int i=0;i<items.length;i++){
String itemIDStr = items[i].getAttribute("ItemID");
NodeList nl = doc.getElementsByTagName("Category");
for (int j = 0; j < nl.getLength(); j++){
Node n = nl.item(j);
NodeList nll = n.getChildNodes();
for(int k=0; k<nll.getLength(); k++){
Node nn = nll.item(k);
streamItemCategory.println(itemIDStr + nn.getNodeValue() + columnSeparator);
}
}
}
I have include a condition by which only the categories for that item should be displayed and when the itemid changes it no more should include the old categories
Can someone tell me how to do it.
Thanks
G