Tag: domdocument

如何将DomDocument传入和传出vba中的函数

我有一个VBA函数,以自己的方式recursion调用自己的目录树的所有分支。 在这个函数中,如果当前目录中的文件符合某个标准,则打开该文件并提取数据。 然后我想将这些数据写入一个XML文件。 由于XML文件可能会或可能不会被每个函数实例更新(可能多次),因此我将当前的XML文件传递到函数中,并且在编写新的节点之后,更新的XML文件需要传递回函数实例调用它。 相关的代码是:1)调用该函数的子对XML文件进行初始化(作为Document),然后将其传递给该函数,从而: Dim XMLSource As DOMDocument Set XMLSource = New DOMDocument FindDir = "mydirectory/path" XMLSource = MyRecursiveFunction(FindDir, XMLSource) 2)recursion函数如下所示: Private Function MyRecursiveFunction(ByVal FindDir As String, ByRef XMLSource As DOMDocument) As DOMDocument 3)这样recursion调用: For Each subfolder In ObjFolder.SubFolders XMLSource = MyRecursiveFunction(subfolder, XMLSource) Next subfolder 4)并返回它的值: MyRecursiveFunction = XMLSource 每当它进入“退出函数”,它将返回一个438错误。 我已经把它写入DOMDocument的部分注释掉了,所以这不是一个格式问题,它只是在这个阶段传入和传出文件。 我使用了一个现有的recursion函数,可以很好地处理传入的string或整数。 它肯定有正确的库加载等所有我的其他XML程序工作。 有任何想法吗? […]

XMLparsing器不知道空白的长度

我有以下XML示例。 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:f="http://kbcfp.com/BoTech/Inferno/Fault" xmlns:base="http://kbcfp.com/BoTech/Inferno/Base" xmlns:h="http://kbcfp.com/BoTech/Inferno/Header" xmlns:ep="http://torstonetech.com/Inferno/FDE"> <SOAP-ENV:Header> <h:optLockSeqNumbers> <h:values><h:editSequenceNumber>1</h:editSequenceNumber><h:modifiedDateTime>2015-01-21T15:33:10+06:30</h:modifiedDateTime><h:modifiedUserId>1005</h:modifiedUserId><h:objectId>100100049</h:objectId><h:optimisticLockObjTypeId>11</h:optimisticLockObjTypeId></h:values> </h:optLockSeqNumbers> </SOAP-ENV:Header> <SOAP-ENV:Body> <ep:AccountAttrs><ep:accountId>100100049</ep:accountId><ep:attrId>100001896</ep:attrId> <ep:AccountAttrs><ep:accountId> </ep:accountId><ep:attrId>100001896</ep:attrId></ep:AccountAttrs> </SOAP-ENV:Body> </SOAP-ENV:Envelope> 我必须阅读这个XML和预期的输出如下。 1st ep:accountId 100100049 ep:attrId 100001896 2nd ep:accountId <!– want to write 1 space in these place –> ep:attrId 100001896 这是我的XMLparsing器代码。 Dim xmlDoc As MSXML2.DOMDocument Set xmlDoc = New MSXML2.DOMDocument xmlDoc.LoadXML […]

用户定义types未定义的窗口10

我有这个从天气API获取天气信息的子。 它适用于Windows 7的计算机,但不是Windows 10.我得到一个“用户定义的types没有定义”的错误,并突出显示“作为新的XMLHTTP的需求作为新的”线。 我试图将DOMDocument更改为DOMDocument60,并试图确保MicrosoftXML V6.0被选中。 Public Sub GetWeather(APIurl As String, sted As String) Dim i As Integer Dim ws As Worksheet: Set ws = ActiveSheet Dim city As String Dim omraade As String Dim Req As New XMLHTTP Dim Weather As IXMLDOMNode Dim wShape As Shape Dim thisCell As Range Dim Resp As New […]

如何使用VBA读取XML属性到Excel?

这是我的代码 <?xml version="1.0" ?> <DTS:Executable xmlns:DTS="www.microsoft.com/abc" DTS:ExecutableType="xyz"> <DTS:Property DTS:Name="PackageFormatVersion">3</DTS:Property> <DTS:Property DTS:Name="VersionComments" /> <DTS:Property DTS:Name="CreatorName">FirstUser</DTS:Property> <DTS:Property DTS:Name="CreatorComputerName">MySystem</DTS:Property> </DTS:Executable> 在这个我能读取元素使用“abc.baseName”和它的值使用“abc.Text”。 它给我的结果是 财产3财产 物业FirstUser 在这个我怎么能读“PackageFormatVersion”为3? 即我知道一些价值是3,但是那个价值是怎么知道的? 我的意思是我必须select我想读的属性。