Web Analytics Made Easy -
StatCounter VBscript the only way to selectNode()? - CodingForum

Announcement

Collapse
No announcement yet.

VBscript the only way to selectNode()?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • VBscript the only way to selectNode()?

    Again at w3schools.com...

    In the XPath tut, they had some "try it yourself" code that kinda irked me. I am unfamiliar with VB and ASP, which is what this looks like:
    Code:
    <html>
    <body>
    <script type="text/vbscript">
    
    set xmlDoc=CreateObject("Microsoft.XMLDOM")
    xmlDoc.async="false"
    xmlDoc.load("cdcatalog.xml")
    
    path="/catalog/cd/price"
    set nodes=xmlDoc.selectNodes(path)
    
    for each x in nodes
      document.write("<xmp>")
      document.write(x.xml)
      document.write("</xmp>")
    next
    
    </script>
    </body>
    </html>
    More importantly, the "CreateObject("Microsoft.XMLDOM"). Is this ASP or VB or...? Will I have to learn this language to utilize XML, XSLT, XPath, etc?

    -S

    [edit]

    I'm guessing that
    Code:
    set nodes=xmlDoc.selectNodes(path)
    Sets up a function/variable, much like something to the effect of
    Code:
    function sayHi(message){
    alert(message)
    }
    sayHi("Hello")
    in JavaScript. However, the "path" is not defined anywhere. It's just... there.

    Again, I'm new to this, so bear with me.

    [edit]
    Last edited by Steveo31; Mar 4, 2004, 12:24 PM.

  • #2
    set xmlDoc=CreateObject("Microsoft.XMLDOM") is VBscript. The JScript (Microsoft's implementation of javascript) equivalent is xmlDoc = new ActiveXObject("Microsoft.XMLDOM"). Look this up in a JScript tutorial but bear in mind that it will only work in IE.

    patrick

    Comment


    • #3
      Ah finally a response!

      If it only works in IE... ferget it.

      Thanks.

      Comment


      • #4
        Originally posted by mpjbrennan
        set xmlDoc=CreateObject("Microsoft.XMLDOM") is VBscript. The JScript (Microsoft's implementation of javascript) equivalent is xmlDoc = new ActiveXObject("Microsoft.XMLDOM"). Look this up in a JScript tutorial but bear in mind that it will only work in IE.

        patrick
        you can use the CreateObject("Microsoft.XMLDOM") in VBscript and in (serverside) JScript both to be used in ASP pages. the New ActiveXObject("Microsoft.XMLDOM") is the clientside (javascript) way to get a xml-dom object and you are right, the activeX will only work in IE
        I am the luckiest man in the world

        Comment


        • #5
          Originally posted by Steveo31
          However, the "path" is not defined anywhere. It's just... there.
          Yes it is, its defined in the line right above the one you quoted:

          Code:
          path="/catalog/cd/price"
          Luke Redpath

          Comment


          • #6
            Originally posted by Luke Redpath
            Yes it is, its defined in the line right above the one you quoted:

            Code:
            path="/catalog/cd/price"
            Wow, I'm pretty dumb.

            </stoopid>

            Comment

            Working...
            X