Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / July 2008

Tip: Looking for answers? Try searching our database.

ReadElementContentAs() throws XmlException

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cody - 23 Jul 2008 19:53 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.