I have the following XML
<Company name="Kinanah Computers">
<Computer Name="Computer" type="Dell">
<Accessory type="screen" model="dell"/>
<Accessory type="mouse" model="dell"/>
<Accessory type="keyboard" model="dell"/>
</Computer>
<Computer Name="Computer" type="HP">
<Accessory type="screen" model="hp"/>
<Accessory type="mouse" model="chinese"/>
<Accessory type="keyboard" model="dell"/>
</Computer>
<Computer Name="Computer" type="HP">
<Accessory type="screen" model="hp"/>
<Accessory type="mouse" model="chinese"/>
<Accessory type="keyboard" model="dell"/>
</Computer>
<Computer Name="Computer" type="acer">
<Accessory type="screen" model="acer"/>
<Accessory type="mouse" model="acer"/>
<Accessory type="keyboard" model="acer"/>
</Computer>
</Company>
what I want to do, is to skip the HP computer if its type is HP, can anybode tell me how to do that?
I'm using the following C# code :
var stream = new StringReader(instanceXml/*the xml above*/);
var reader = XmlReader.Create(stream);
var hpCount = 0;
reader.MoveToContent();
while (reader.Read())
{
if(reader.NodeType == XmlNodeType.Element)
{
if(reader.GetAttribute("Name") == "Computer" && reader.GetAttribute("type") == "HP")
{
if(hpCount >1)
{
reader.Skip();
continue;
}
hpCount++;
}
}
}
but the Skip isn't working, next element that got read is
<Accessory type="screen" model="hp"/>
any help of how to skip these lines ? thank you.