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 GutoThomas · Jun 26, 2012 at 03:14 AM · mobilexmlread

Get external .xml in mobile

Hey guys, I recently asked about an error I've got when try to get an external .xml file in mobile. I got an answers, understood my problem, but I couldn't get forward with the problem's fix.

I have the .xml placed in the Resources folder, but I don't know how to get this files as .xml files with Resources.Load in order to read this file using XmlReader.Read();

The best would be if I could get the path for this .xml in the mobile, so I could use XmlReader.Create(thisPath);

But I definitely got stuck in this and I can't get any results!

Anyone knows a way to go through this?

Thanks from now!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Mortoc · Jun 26, 2012 at 04:29 AM

You'll want to load the xml file as a Unity TextAsset

Then pass the text property from that to XmlReader.Create()

Comment
Add comment · Show 3 · 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
avatar image GutoThomas · Jun 26, 2012 at 04:38 AM 0
Share

Hmm, that's interesting! I'll check it out in a $$anonymous$$ute and come back to post what I get. :)

avatar image GutoThomas · Jun 26, 2012 at 05:00 AM 0
Share

Actually, I'm getting a null reference exception error in the line where I call the print.

 void Awake () {
     
     _language$$anonymous$$anager = this;
     DontDestroyOnLoad(this);
 
     languageFiles  = new TextAsset[3];
     
     languageFiles[0] = Resources.Load("arachnaZone_EN.xml") as TextAsset;
     languageFiles[1] = Resources.Load("arachnaZone_PTBR.xml") as TextAsset;
     languageFiles[2] = Resources.Load("arachnaZone_SN.xml") as TextAsset;
     
     print(languageFiles[0].text);
     
 }

I have the folder 'Resources' in the Assets folder with these 3 .xmls in it.

Without the .xml extension it worked! Thanks!

Anyway, when calling XmlReader reader = XmlReader.Create( languageFiles[(int)_curLanguage].text); I get the following error:

ArgumentException: Illegal characters in path.

avatar image systemexitzero · Oct 20, 2012 at 07:36 AM 0
Share

Anyway, when calling XmlReader reader = XmlReader.Create( languageFiles[(int)_curLanguage].text); I get the following error: ArgumentException: Illegal characters in path.

Per the XmlReader.Create docs, passing a string to `XmlReader.Create()`, "Creates a new XmlReader instance with specified URI"; `XmlReader` interprets `languageFiles[0].text` as the path to the text file rather than the contents of the file, which is why you are getting an exception for "Illegal characters in path". Ins$$anonymous$$d, you should interpret `languageFiles[0].text` as a text stream first, and pass that to `Create()`.

Try using the System IO namespace in the file and change your code above to

 XmlReader reader = XmlReader.Create( new StringReader(languageFiles[(int)_curLanguage].text))

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

6 People are following this question.

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

Related Questions

read XML work in editor but not in final build 2 Answers

Play an array of audioclips from HDD. 1 Answer

Reading XML Data C# 2 Answers

Read STRING AS XML TO SHOW LIST 1 Answer

pixel terrain texture mobile 0 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