我希望将XML文件的内容转换为excel VBA中的String变量,以便我可以在文件中搜索特定的字符串。
但是我不知道如何从XML文件到String变量进行初始转换。 到目前为止,我所能做的就是加载XML文档,从那里我就被卡住了。
Public Function DetermineSpecifiedChange(ByVal vstrInputGBOMPath As String, ByVal vstrInputPDPPath As String) Dim strPDPString As String Dim strGBOMString As String Dim xmlGBOM As New DOMDocument60 Dim xmlPDP As New DOMDocument60 strPDPString = xmlPDP.Load(vstrInputPDPPath) End Function到目前为止,所有这些返回都是“True”,表示正在加载文件。
我如何将XML文件转换为字符串?
I'm looking to convert the contents of an XML file into a String variable in excel VBA so that I can search the file for a specific string.
However I don't know how to do the initial conversion from XML file to String variable. All I've been able to do so far is load the XML document, and from there I'm stuck.
Public Function DetermineSpecifiedChange(ByVal vstrInputGBOMPath As String, ByVal vstrInputPDPPath As String) Dim strPDPString As String Dim strGBOMString As String Dim xmlGBOM As New DOMDocument60 Dim xmlPDP As New DOMDocument60 strPDPString = xmlPDP.Load(vstrInputPDPPath) End FunctionSo far all this returns is "True", signifying that the file is being loaded.
How would I go about converting the XML file into a string?
最满意答案
这是一种做你要求的方法:
Dim FSO As Object : Set FSO = CreateObject("Scripting.FileSystemObject") Dim strXml As String strXml = FSO.OpenTextFile("C:\myfile.xml").ReadAllHere's a way to do what you ask:
Dim FSO As Object : Set FSO = CreateObject("Scripting.FileSystemObject") Dim strXml As String strXml = FSO.OpenTextFile("C:\myfile.xml").ReadAll更多推荐
XML,String,file,Function,文件,电脑培训,计算机培训,IT培训"/> <meta name="d
发布评论