IgnoreWhitespace breaks IsStartElement

raikorei

New Member
I've been trying to read an xml file in c#. Though I bumped into a problem, one I can't explain.So, I have a very simple loop for my xml file:\[code\]while (reader.Read()){ // Only detect start elements. if (reader.IsStartElement()) { // Get element name and switch on it. switch (reader.Name) { ...\[/code\]And then I check if it's one of the elements I want to read. Though, for some reason when I set IgnoreWhitespace to true (in the \[code\]XmlReaderSettings\[/code\] I used the create the reader) the \[code\]IsStartElement\[/code\] returns true for one of my elements, even though it is a start element... The weird thing is that it's always the same element, so it skips all my "toughness" elements. Though when I keep \[code\]IgnoreWhitespace\[/code\] on \[code\]false\[/code\], it does work...Also, here's a piece of the xml, it has a whole lot more cards in it, though all are structured exactly the same.\[code\] <card> <id>234431</id> <lang>English</lang> <name>Furor of the Bitten</name> <altart></altart> <cost>R</cost> <color></color> <type>Enchantment - Aura</type> <set>Innistrad</set> <rarity>Common</rarity> <power></power> <toughness></toughness> <rules>Enchant creature Enchanted creature gets +2/+2 and attacks each turn if able.</rules> <printedname></printedname> <printedtype></printedtype> <printedrules></printedrules> <flavor></flavor> <watermark></watermark> <cardnum></cardnum> <artist></artist> <sets>Innistrad Common</sets> <rulings></rulings> </card> <card> <id>233248</id> <lang>English</lang> <name>Gallows Warden</name> <altart></altart> <cost>4W</cost> <color></color> <type>Creature - Spirit</type> <set>Innistrad</set> <rarity>Uncommon</rarity> <power>3</power> <toughness>3</toughness> <rules>Flying Other Spirit creatures you control get +0/+1.</rules> <printedname></printedname> <printedtype></printedtype> <printedrules></printedrules> <flavor></flavor> <watermark></watermark> <cardnum></cardnum> <artist></artist> <sets>Innistrad Uncommon</sets> <rulings></rulings> </card>\[/code\]Any idea why this happens?
 
Back
Top