Dim strXML, xmlSectionName
'该行仅为实例,前面为xml文件路径,后面为查找的tag名称
GetXml "http://mfl-int:7401/MFL/getFundDetail/v1.0/REST?
fundID=0010§ion=FundInformation,AgMrgBkdSctrDiversificationPct,AssetA
llocation,AssetAllocationOverTime,AssetClassDivPct,AssetBackedSectorDivPc
t,CommodityInstrument,CompByIntrumentPct,CompByQualityPct,CorpSectorDiv,C
ountryDivPct,CreditQuality,CurrencyDivPct,DurationDistribution,FundFacts,
GeoDistribution,HistoricalFundInfo,MajorMarketSector,MaturityDistribution
,OtherGovSectorDiv,PortfolioDiv,RealEstateDivPct,RevenueDiv,StyleMap,FixB
oxStyleMap,SubjectToAMT,Top10Holdings,Top5Issuers,Top5States,PortfolioDat
a,Global,Composition,Disclosure&appCode=NETBENEFITS","RatingsTabSuppressI
nd","FundInformation"
'定义并输出返回的值
RatingsTabSuppressInd = strXML
Msgbox RatingsTabSuppressInd
Function GetXml (ByVal strXmlFilePath,ByVal xmlNodeName,ByVal
xmlSectionName)
Dim xmlDoc,xmlRoot
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = False
xmlDoc.load strXmlFilePath
If xmlDoc.parseError.errorCode <> 0 Then
MsgBox "XML文件格式不对,原因是:" & Chr(13) &
xmlDoc.parseError.reason
Exit Function
End If
'获得根结点
Set xmlRoot = xmlDoc.documentElement
'获得第二层结点
xmlGetFloorTwo xmlRoot, xmlNodeName, xmlSectionName
GetXml = True
End Function
'获得第二层结点
Function xmlGetFloorTwo(byval xmlNode, byval xmlNodeName, byval
xmlSectionName)
If xmlNode.nodeName <> "Response" Then
For Each childNodeItem In xmlNode.ChildNodes
If
childNodeItem.nodeName = "Response" Then
xmlGetFloorThree childNodeItem,xmlNodeName, xmlSectionName
End If
Next
End If
End Function
'获得第三层结点
Function xmlGetFloorThree(byval xmlNode, byval xmlNodeName, byval
xmlSectionName)
If xmlNode.nodeName <> "Sections" Then
For Each childNodeItem In xmlNode.ChildNodes
If
childNodeItem.nodeName = "Sections" Then
xmlGetFloorFour childNodeItem, xmlNodeName, xmlSectionName
End If
Next
End If
End Function
'获得第四层结点
Function xmlGetFloorFour(byval xmlNode, byval xmlNodeName, byval
xmlSectionName)
If xmlNode.nodeName <> xmlSectionName Then
For Each childNodeItem In xmlNode.ChildNodes
If
childNodeItem.nodeName = xmlSectionName Then
xmlRecursion childNodeItem, xmlNodeName
End If
Next
End If
End Function
Function xmlRecursion(byval xmlNode,byval strNodeName)
If xmlNode.nodeName = strNodeName And xmlNode.hasChildNodes Then
If xmlNode.childNodes.item(0).nodeName = "#text" Then
strXML = xmlNode.nodeName & ":" &
xmlNode.childNodes.item(0).nodeValue & Chr(13)
End If
End If
If xmlNode.hasChildNodes Then
For Each childNodeItem In xmlNode.ChildNodes
If childNodeItem.hasChildNodes Then
xmlRecursion childNodeItem,strNodeName
End If
Next
End If
End Function