Search Unity

XML and IEnumerator problems on webgl

Discussion in 'Web' started by shivansps, Mar 10, 2015.

  1. shivansps

    shivansps

    Joined:
    Feb 26, 2014
    Posts:
    60
    When i switch to WebGL platform i get script error on my XML lang script that does work for other platform.

    Code (JavaScript):
    1.     public function setLanguage ( path : String, language : String) {
    2.         var xml : XmlDocument = new XmlDocument();
    3.         xml.Load(path);
    4.        
    5.         Strings = new Hashtable();
    6.         var element : XmlElement = xml.DocumentElement.Item[language];
    7.         if (element) {
    8.             var elemEnum : IEnumerator = element.GetEnumerator();
    9.             while (elemEnum.MoveNext()) {
    10.                 Strings.Add(elemEnum.Current.GetAttribute("name"), elemEnum.Current.InnerText);
    11.             }
    12.         } else {
    13.             Debug.LogError("The specified language does not exist: " + language);
    14.         }
    15.     }
    The errors are

    BCE0019: 'InnerText' is not a member of 'Object'.
    BCE0019: 'GetAttribute' is not a member of 'Object'.

    I have no idea if its something not implemented yet, or a limitation on webgl, it does work on webplayer.
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    I guess your JS file gets compiled using "#pragma strict", as that is required for AOT platforms like WebGL. This enforces type checking. "elemEnum.Current" is a generic object - you probably need to cast it to XmlElement for this to compile.
     
  3. shivansps

    shivansps

    Joined:
    Feb 26, 2014
    Posts:
    60
    Thank you, casting it as XmlElement worked, it was kinda confusing because it worked ok whiout that for webplayer and windows, and it was my only script to have a issue with webgl.