Murali I have another question
from the xml below I need the following 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>
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 know I have to check somewhere where when the itemId changes it no more should read the previous ones categories but not sure where to include the condition
As again your help needed
Thanks
G