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
1
Question by Robert Carlsson · Dec 04, 2014 at 12:35 PM · wwwxmlcrossdomain

What to do after setting up crossdomain.xml

My game needs to get a string from a xml doc on my website. This all worked fine when the game was in standalone, but due to security reasons Webplayers are a bit more complicated.

I've set up my crossdomain.xml at my websites root folder and everything is working out fine. But here is the problem. I know how to get a string from xml in standalone from website. I know how to set up the crossdomain. But I don't know how to get the value after setting up the domain.

Either I'm really stupid right now, or there is something missing in the docs.

Should the string I want to get be in the crossdomain file? Or what am I supposed to do now?

As it is now I have a crossdomain file looking like this:

 <?xml version="1.0"?>
 
 <cross-domain-policy>
 <allow-access-from domain="*"secure="false"/>
 </cross-domain-policy>

at: http://WEBSITE.com/crossdomain.xml

and the string at: http://WEBSITE.com/MasterIP.xml

How should I go about getting the string now?

My old code did this, which works on standalone:

 IEnumerator GETIP(){
 
         WWW www = new WWW("http://WEBSITE.com/MasterIP.xml");
         while(!www.isDone)
         {
             yield return new WaitForSeconds(0.1f);
         }
         string wwwtext = ASCIIEncoding.ASCII.GetString(Encoding.Convert(Encoding.UTF8,Encoding.ASCII,www.bytes));
         Debug.Log("new xmldoc");
         XmlDocument result = new XmlDocument();
         Debug.Log("loadxml");
         try
         {
             result.LoadXml(wwwtext);
         }
         catch{}
 
         Debug.Log(result.InnerText.ToString());
         masterIP = result.InnerText.ToString();
         return false;
     }

It returns the IP without a problem. But when using Webplayer and crossdomain, how should I go about to fetch the IP?

First time using xml and WWW in unity so sorry if the answer is obvious.

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
1
Best Answer

Answer by Bunny83 · Dec 04, 2014 at 12:47 PM

You don't need to do anything. When Unity detects that you try to access a domain different than your hosting domain it will automatically request the crossdomain.xml file on that foreign server. If the crossdomain is missing, somehow not formatted right or doesn't allow access your request will fail with a security exception. Otherwise you will get the same result as in a standalong build.

If the file you want to access is hosted on the same domain as your webplayer there's no need for a crossdomain policy since you don't have "crossing domains". The webplayer can access anything on the domain it's hosted on. Of course only if the resource is actually reachable from the internet. For this you should check your server configuration (htaccess, ...)

Comment
Add comment · Show 2 · 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 Robert Carlsson · Dec 04, 2014 at 12:55 PM 0
Share

Ah okay then I understand. Well since I'm currently testing from the editor I'm not on the same domain, that's why I thought I needed it.

This gave me a lot more clarity then the Unity docs did, thanks a lot!

(Just tested it again and it works now, had a typo in the crossdomain file -.-).

avatar image Bunny83 · Dec 04, 2014 at 01:20 PM 0
Share

The crossdomain.xml parser is quite "sensitive". It should be encoded in ASCII. So if saved with norepad make sure you don't save as utf8. Actually utf8 and ASCII would be compatible, however notepad adds a BO$$anonymous$$ at the start which usually screws up the parser. You might want to have a look at the SecuritySandbox page.

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

26 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

web page html parsing 1 Answer

Posting raw XML data to web - no parameter name 2 Answers

Returning correct result after uploading 0 Answers

WebGL WWW and Localhost CORS 0 Answers

How to read xml file using javascript? 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