Hi Nischal, The code below loads up your xml document and then for each FastTrack node that contains the condition attribute grabs the relevant xml node (as described in your email). btw, I'm sure there is a more efficient way of doing this as well. Hope this helps.
Note that I've also added a root element as the xml you supplied was not valid. static void Main(string[] args) { // // TODO: Add code to start application here // string _sXml = "<yourDoc>" + "<ProductType>" + "<FastTrack condition='Equals'>" + "<Code1>Bye</Code1>" + "<Code2>Bye Bye</Code2>" + "</FastTrack>" + "</ProductType>" + "<Property>" + "<FastTrack condition='NotEquals'>" + "<Code1>Hello</Code1>" + "<Code2>Hi</Code2>" + "</FastTrack>" + "</Property>" + "</yourDoc>"; XmlTextReader xtr = new XmlTextReader(new StringReader(_sXml)); XmlDocument xdoc = new XmlDocument(); xdoc.Load(xtr); XmlNode docElement = xdoc.DocumentElement; XmlNodeList xNodeList = docElement.SelectNodes("//FastTrack/@condition"); string sXml1 = null; string sXml2 = null; foreach(XmlNode xnode in xNodeList){ if (xnode.InnerText == "Equals"){ sXml1 = xdoc.SelectSingleNode("yourDoc/ProductType").InnerXml.ToString(); } else if (xnode.InnerText == "NotEquals"){ sXml2 = xdoc.SelectSingleNode("yourDoc/Property").InnerXml.ToString(); } } Console.WriteLine(sXml1); Console.WriteLine(sXml2); Console.ReadLine(); } Regards, Serdar Kilic | skilic.com ----- Original Message ----- From: "Nischal Muthana" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, June 07, 2002 9:45 AM Subject: [DOTNET] XMLTextReader childNodes > Hello All > > I have an xml like the following > > <ProductType> > <FastTrack condition="Equals"> > <Code1>Bye</Code1> > <Code2>Bye Bye</Code2> > </FastTrack> > </ProductType> > <Property> > <FastTrack condition="NotEquals"> > <Code1>Hello</Code1> > <Code2>Hi</Code2> > </FastTrack> > </Property> > > I am using the XMLTextReader to read the file. I want > to get the @condition attribute and do a check and > thereby get and thereby get the Code1 and Code2 of > both the <ProductType> and <Property> > > Can someone help me. > > Thanks > Nischal > > __________________________________________________ > Do You Yahoo!? > Yahoo! - Official partner of 2002 FIFA World Cup > http://fifaworldcup.yahoo.com > > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.