anatar02
12 years agoContributor
How to read the child node with different parent node
Hi team, I have a xml with contains of two diffrent parent nodes.. with same child node name....here i wanted to retrivew the 2nd child node from 2nd parent nide? here my xml and code ...
- 12 years agoIt seems that the following line is incorrect: Log["Message"](xmlNode.item(0).text);
You are using 0 as item index. This code should work: Log["Message"](xmlNode.item(i).text);
BTW, the cycle code is too complicated. If you have only 2 nodes then the cycle is not necessary:
Log["Message"](xmlNode.item(0).text);
Log["Message"](xmlNode.item(1).text);
If there are more nodes then I suggest this:
if (xmlNode != null)
{
for (var i = 0; i < xmlNode["length"]; i++)
Log["Message"](xmlNode.item(i).text);
}