Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 9th, 2007, 02:16 PM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading XML unexpected EndElement

Hello,
ive started to experiment with using XML to load data in to my application. heres a short snippit from my xml sheet
Code:
<AnimationSet name="orc">
        <Animation name="Move">
            <Direction compasDir="North">    
                <spriteSheet>Content//Art//Sprite//orc_forward_north.png</spriteSheet>
                <startFrame>0</startFrame>
                <endFrame>9</endFrame>
            </Direction>

Ive set up and xml reader, and ive got some simple if statements that check the name of the current element and then pull out the expected text or attribute.

this works fine for all nodes apart from the startFrame node which keeps getting read as a EndElement, so i cant read any data out of it. At first i thought it might have something to do with the slashes in the previous line, but it still happens that element has noral text in it. any ideas? heres my processing code.

Code:
while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "AnimationSet")
                    {
                        //pull out data
                    }
                    else if (reader.Name == "Animation")
                    {
                        //pull out data
                    }
                    else if (reader.Name == "Direction")
                    {
                       //pull out data
                    }
                    else if (reader.Name == "spriteSheet")
                    {
                        spriteSheet = reader.ReadElementContentAsString();
                    }
                    else if (reader.Name == "startFrame")
                    {

                        startFrame = reader.ReadElementContentAsInt();
                    }
                    else if (reader.Name == "endFrame")
                    {
                        endFrame = reader.ReadElementContentAsInt();
                    }
                }
           }
its able to read endFrame no problem, why whould start frame be any different?

Thnaks for you help!






Similar Threads
Thread Thread Starter Forum Replies Last Post
reading XML with relationships regulardude C# 2005 2 February 15th, 2008 04:57 AM
reading a XML file connect2sandep XML 1 December 14th, 2006 04:50 AM
reading a XML file connect2sandep General .NET 0 December 13th, 2006 02:10 PM
Reading XML evidica C# 0 July 25th, 2006 10:33 AM
Reading XML from ASP texasraven Classic ASP XML 2 February 26th, 2004 03:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.