public static void Main()
string XML = "<XMLResult status=\"SUCCESS\" version=\"v3.0.1-202109020235\">"+
"<Result count=\"1\" id=\"TEST0\" returned=\"1\">"+
"<Part alert-prediction-date=\"01-Nov-2021\""+
" availability-yteol=\"4 - 8\" avg-part-price=\"\""+
" cage-code=\"56637\" caps_categoryid=\"C0565\"> "+
" <Partdetails count=\"1\" returned=\"1\" type=\"DETAILS\" >"+
" <Details category=\"Resistors\" "+
" desc=\"Qualification of products or family of products that have met the qualification requirements set by defense logistics agency.\" "+
" id=\"3901637903\" name=\"DLA Qualification\"/> "+
" <Details category=\"Active Part Master\" "+
" desc=\"Hyperlink to the manufacturer's web page\" "+
" id=\"3901637911\" name=\"Mfr Part Page\"/>"+
" <Details category=\"Active Part Master\""+
" desc=\"Country of origin\" id=\"3901637912\" name=\"Country/Region of Origin\">Taiwan</Details> "+
" <Details category=\"Active Part Master\" "+
" desc=\"Important features of the part\""+
" id=\"3901637913\" name=\"Features\"/> "+
XmlDocument doc = new XmlDocument();
XmlElement root = doc.DocumentElement;
XmlNodeList nodes = root.SelectNodes("//Result");
int countryCodeNodeNumber = 0;
foreach (XmlNode node in nodes)
XmlNode parent = node.SelectSingleNode("Part");
XmlNodeList test2 = parent.SelectNodes("Partdetails/Details/@desc");
foreach (XmlNode desc in test2)
if (desc.InnerText =="Country of origin")
countryCodeNodeNumber = count ;
Console.WriteLine("test2.inertext[ " + desc.InnerText );
Console.WriteLine("countryCodeNodeNumber [ " + countryCodeNodeNumber);
XmlNode test3 = parent.SelectSingleNode("Partdetails/Details["+countryCodeNodeNumber+"]");
if (test3.InnerText == null)
Console.WriteLine("NO WORK ");
Console.WriteLine("test3.inertext[ " + test3.InnerText );