Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sintua · Nov 17, 2012 at 11:03 PM · xmlupgrading

Upgrading to 4.0 breaks my XML reader

Perhaps there's another workaround or explanation for this, but I didn't see anything in the update that should be impacting this.

The error that fires when the project is upgraded to 4.0 is:

XmlException: Text node cannot appear in this state. Line 1, position 1. This fires at "xmlStory.LoadXml(stringReader.ReadToEnd());"

the relevant code posted below. Note the BOM stripper worked fine before, but after the upgrade it sends the error whether I use an XML file with a BOM or not (tried both).

 // Gets ALL the scenes.
     void GetScenes ()
     {
         //initialize
         scenes = new Dictionary<string,Scene>();
         
         //TODO: doublecheck this isnt cvausing mass slowdown
         //BOM STRIPPER
         XmlDocument xmlStory = new XmlDocument();
         System.IO.StringReader stringReader = new System.IO.StringReader(xmlScriptRef.text);
         stringReader.Read(); // skip BOM
         xmlStory.LoadXml(stringReader.ReadToEnd());
                 
         //XmlDocument xmlStory = new XmlDocument();//new xmlDoc
         //xmlStory.LoadXml(xmlScriptRef.text);//load file
         
         XmlNodeList sceneList = xmlStory.GetElementsByTagName("scene"); //array of scenes
         
         foreach (XmlNode sceneInfo in sceneList)//foreach scene in list
         {
             Scene newScene = new Scene(sceneInfo); //builds scene out of xmlnode data
             scenes.Add(newScene.title, newScene); // add whole obj dictionary in the scenes[].
         
             if (currentScene == null) //if there isnt a currentscene yet
             {
                 ChangeScene(newScene.title);//change to first scene
                 //currentScene=newScene;//put in the first scene you get
             }
         }
     }
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image asafsitner · Nov 17, 2012 at 11:40 PM 0
Share

I second that. Unity4 apparently treats X$$anonymous$$L files differently. I could get around using XmlSerializer, but it's obviously not ideal.

avatar image sintua · Nov 17, 2012 at 11:51 PM 0
Share

NOTE: For those interested, here's where I got the bom stripper in the first place: http://answers.unity3d.com/questions/10904/xmlexception-text-node-canot-appear-in-this-state.html

avatar image sintua · Feb 27, 2013 at 07:09 PM 0
Share

I ended up switching to TSV anyway, so I'm not sure if this problem was ever resolved.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Tent · Oct 08, 2013 at 02:09 PM

Try removing line: stringReader.Read(); // skip BOM

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

JSON vs XML for Unity C# 1 Answer

C# Saving Values to XML 1 Answer

Parse xml with unknown fields 1 Answer

Best practice to store and load a specific set of objects? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges