作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下代码,它 ping 雅虎财经,并下载特定证券/股票的配置文件:
Public Function getETFDetails(theSymbol As String)
Dim xmlhttp As Object
Dim strURL As String
Dim x As String
Dim sSearch As String, myDIV As String, theDeets As String
'theSymbol = "SPY"
strURL = "http://finance.yahoo.com/q/pr?s=" & theSymbol & "+Profile"
DeleteUrlCacheEntry (strURL)
Set xmlhttp = CreateObject("msxml2.xmlhttp")
With xmlhttp
.Open "get", strURL, False
.send
x = .responsetext
End With
Set xmlhttp = Nothing
sSearch = "Fund Summary"
myDIV = Mid(x, InStr(1, x, sSearch) + Len(sSearch))
sSearch = "<td>"
myDIV = Mid(myDIV, InStr(1, myDIV, sSearch) + Len(sSearch))
theDeets = Left(myDIV, InStr(1, myDIV, "</td>") - 1)
getETFDetails = theDeets
End Function
The investment seeks to provide investment results that, before expenses,
generally correspond to the price and yield performance of the S&P 500® Index.
最佳答案
VBA 中没有内置的“HTML/XML 解码”功能,但您可以将字符串写入 XML 文档并读回文本。例如:
Set doc = CreateObject("Msxml2.DOMDocument.6.0")
strXML = "S&P 500"
doc.LoadXML "<root>" & strXML & "</root>"
strDecoded = doc.Text
关于xml - 如何将 XML 中的特殊字符转换为 VBA 中的可读字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31328863/
我是一名优秀的程序员,十分优秀!