excel - Using VBA to request specific attribute on online XML -


recently trying write custom function in vba excel fetch stock information webservice. however, resulting xml written this:

<comportamentopapeis> <papel codigo="bova11" nome="ishares bova ci"         ibovespa="" data="29/05/2015 17:29:57"         abertura="52,04" minimo="51,28" maximo="52,24"         medio="51,64" ultimo="51,35" oscilacao="-1,98"/> </comportamentopapeis> 

i tried write following piece of code, run it, says method or data not found.

    function stock(sname string, sitem string, optional surl = "") variant     dim ohttp new msxml2.xmlhttp60     dim xmlresp msxml2.domdocument60     dim result variant     on error goto eh       if surl = ""         surl = "http://www.bmfbovespa.com.br/pregao-" & _                 "online/executaacaoajax.asp?codigopapel="     end if      'open request , send     ohttp.open "get", surl & sname, false     ohttp.send      'get response xml     set xmlresp = ohttp.responsexml      ' item     stock = xmlresp.selectsinglenode("/comportamentopapeis/papel"). _                  atrributes.getnameditem(sitem).text       ' examine output of these in immediate window     debug.print sname     debug.print xmlresp.xml  cleanup:     on error resume next     set xmlresp = nothing     set ohttp = nothing exit function eh:     stock = cverr(xlerrvalue)     goto cleanup end function 

in particular case, sname = bova11 , sitem = nome

does know went wrong? referenced msxml v6.0

atrributes.getnameditem(sitem).text - there typo in attributes


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -