Alvin,
>if (tr.Name =="Type")
>{
>(tr.ReadString().ToString());
>if (tr.ReadString().ToString() == "Door Style")
This looks suspect. It looks like the first tr.ReadString will read the <Entry> node so the following ReadString will start with the next <Style> element.
Is the XML file well formed? If so, you may want to consider using the XmlDocument or XmlNodeReader class to traverse the file. They are much easier to work with than XmlTextReader.
>Hello,
>
>Im trying to retrieve a value for a given tag. I cant seem to get the code below to work. I can only retrieve the value of StyleBlockName and Door Style value but I cant seem to get the value for Wall Door.
>
>The XML file is below: This is only a portion of the XML file.
>
>What Im trying to do is retrieve the value of the Entry tag after finding either Type Element value = Door Style or Type Element value = Wall Door
>
>Thanks for your help,
>Alvin
>
><StyleBlockInfo>
><StyleBlockName>Default Style</StyleBlockName>
><Style>
><Type>Door Style</Type>
><Entry>Mission Hill</Entry>
></Style>
><Style>
><Type>Wall Door</Type>
><Entry>65</Entry>
></Style>
></StyleBlockInfo>
><StyleBlockInfo>
><StyleBlockName>Style A</StyleBlockName>
><Style>
><Type>Door Style</Type>
><Entry>Vermont</Entry>
></Style>
><Style>
><Type>Wall Door</Type>
><Entry>68</Entry>
></Style>
></StyleBlockInfo>
>
>
>XmlTextReader tr = new XmlTextReader("C:\\NOVEMBERTEST.XML");
>tr.WhitespaceHandling = WhitespaceHandling.None;
>
>while(tr.Read())
>{
>if (tr.NodeType == XmlNodeType.Element)
>{
>if (tr.Name == "StyleBlockName")
>{
>list2.Items.Add(tr.ReadString().ToString());
>list2.Items.Add(tr.Value.ToString());
>}
>if (tr.Name =="Type")
>{
>(tr.ReadString().ToString());
>if (tr.ReadString().ToString() == "Door Style")
>{
>tr.Read();
>list2.Items.Add(tr.ReadString().ToString());
>}
>
>if (tr.ReadString().ToString() == "Wall Door")
>{
>tr.Read();
>list3.Items.Add(tr.ReadString().ToString());
>}
>}
>}