Go to a specific node in the nodelist

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to go to a specific node in a XmlNodeList by its number (I know that I
want the 5th node in the list, but I do not know any information about the
element or attributes contained at the node. Does anyone know of a way to do
this without looping through foreach (node in nodelist) ?

Thanks you
 
Hi there... You can index it... Like this

private string GetNodeName(XmlNodeList list, int index) {
string retval = string.Empty;

if (list != null && list.count >= index)
retval = list[index].Name;

return retval;
}

Regards,
 
XmlNodeList xmlNodeList=xmlDocument.GetElementByTagName("TABLE");
if (xmlNodeList.Count>4)
{
XmlNode the5thXmlNode=xmlNodeList[5];
.....
}
 
Back
Top