my code is the following:
the Read() method positions the cursor on the <condition> tag (verified
with debugger).
XmlReaderSettings s = new XmlReaderSettings();
s.IgnoreComments = true;
s.IgnoreWhitespace = true;
s.IgnoreProcessingInstructions = true;
using (XmlReader reader = XmlReader.Create("class.xml", s))
{
reader.Read();
reader.ReadElementContentAsString();
}
the xml is:
..
<condition> test </condition>
..
Then an Exception is thrown which reads (translated from german):
The 'ReadElementContentAs()' method is not allowed to be called on
elements with sub-elements. line 7, position 12.
I do not understand this, in <condition> there is definitely no sub-element.
Joe Fawcett - 24 Jul 2008 08:29 GMT
I can't reproduce that with your example code, are you certain that you're
on the correct element?
Have you output reader.LocalName?

Signature
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
> my code is the following:
> the Read() method positions the cursor on the <condition> tag (verified
[quoted text clipped - 24 lines]
> I do not understand this, in <condition> there is definitely no
> sub-element.