Passing xml element data to a javascript/asp variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheLymner
    New Member
    • Aug 2007
    • 2

    Passing xml element data to a javascript/asp variable

    I have, what I believe, is a rather simple question. However, I cannot find the answer anywhere on the web nor in any of the library of xml or javascript/asp books available. How do I pass and store an xml element data (an interger) into a javascript/asp variable? I am not going to display the data (that I can do easily), rather the data is going to used to deteremine how the rest of the parent data is going to be displayed in any of 90 different places on the screen. It will determine not only the where but the size and the order of the display.
  • vituko
    New Member
    • Dec 2006
    • 48

    #2
    1- XMLHttpRequest -> responseXML :

    dom

    var = node.firstChild .data ;

    node : you can access it by id or tagName : getElementById / getElementsByTa gName (returns array).
    firstChild or childNodes [i] : the textNode you are looking for

    2- XMLHttpRequest -> responseText + regular expressions

    Comment

    • TheLymner
      New Member
      • Aug 2007
      • 2

      #3
      "That was easy" I found a simple solution shortly after posting the request.

      <xsl:template name="TEST" match="rack"> [place in head]

      <script type="text/JavaScript">
      var units='<xsl:val ue-of select="./slots"/>' [Stores the value of the element
      /slots/ into js variable "units"]

      var pxs=units * 30 [times the value of units by 30 and store it in variable "pxs"]

      var nameNode='<xsl: value-of select="./hostName"/>' [Store the value of /hostName/ into js variable "nodeName"]

      document.write ('<div class="host" style="position :absolute; z-index:42; top:0px; left:0px; width:200px; height:'+pxs+'p x">'+nameNode+' </div>')
      [Write the div and the variables]
      </script>


      TheLymner

      Comment

      • vituko
        New Member
        • Dec 2006
        • 48

        #4
        Cool, I've never worked with xsl. Interesting approach.

        Comment

        Working...