Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-3465

Android: XML Cannot call method parseString if only defined inside an event listener

    Details

      Description

      {html}<div><p>On Android, If parseString is only defined inside an event
      listener then you will get an error.<br></p>
      <h3>Note</h3>
      <p>This only happens until you define it outside of the
      eventListener once. After that it will work fine in that
      application even if it is inside an event listener. In order to
      reproduce this error you MUST create a new application.</p>
      <p>Step 1: Create a NEW application<br>
      Step 2: Paste the example below into app.js<br>
      Step 3: Run the app<br>
      Step 4: Click 'Find Foo'<br>
      Step 5: Notice Runtime Error (picture of error attached)</p>
      <pre>
      <code class=
      "javascript">var xmlString = '<items><foo>FOO</foo><bar>BAR</bar></items>';

      var window = Ti.UI.createWindow({ backgroundColor: 'green' });

      var button = Ti.UI.createButton({ title: 'Find Foo', height: 60, width: 100, top: 40 });
      button.addEventListener('click', function(e){ var xml = Titanium.XML.parseString(xmlString); var element = xml.getElementsByTagName("foo"); Ti.API.info( element.item(0).text ); });

      window.add(button);
      window.open();</code>
      </pre>
      <h3>Tested on</h3>
      <p>TiSDK 1.6.1, Android SDK 2.1</p></div>{html}

        Attachments

          Activity

            People

            • Assignee:
              nhuynh Natalie Huynh
              Reporter:
              jalter Jon Alter
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-2972
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration