2 Replies Latest reply on Aug 28, 2008 6:43 AM by Marco Sgna

    How to get a string of an HTML element

    Marco Sgna
      Imagine a normal web page with its tags. I have to get the value of a precise element and convert it to a String in order to show it in a TextField. Specifically, I have to take a precise cell of a table and insert it in a string.

      Does AIR help me with some method that catches specific elements of a HTML code or have I to parse the string of the entire HTML and try to reach the wanted value?

      In this last case, how do I convert the entire HTML of a page into a string?

      Any other ideas are welcome.

      Thanks.
        • 1. How to get a string of an HTML element
          Dr. Fred Mbogo Level 1
          quote:

          Originally posted by: Marco Sgna
          Does AIR help me...
          No, but I don't see that it has to. I presume you're writing an AIR app with HTML and JavaScript. If so, you can query and modify the HTML's DOM tree with JavaScript. Then, still using JavaScript, you pass it off to the AIR side, using the "AIR aliases" APIs. So:

          <table><tr><td id="foo">bar</td></tr></table>
          <script>var mycontent = document.getElementById('foo').innerHTML; // variable equals "bar" now</script>

          quote:

          how do I convert the entire HTML of a page into a string?
          document.toString(), perhaps.
          • 2. Re: How to get a string of an HTML element
            Marco Sgna Level 1
            The real problem is that I am NOT the editor of the web page, and I have no way to contact him... :-)

            Anyway it's a step beyond, I'll see what I can do. Thanks.