Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 如何在xml元素中添加字符-VBA_Excel_Xml_Vba - Fatal编程技术网

Excel 如何在xml元素中添加字符-VBA

Excel 如何在xml元素中添加字符-VBA,excel,xml,vba,Excel,Xml,Vba,下面是XML节点。我正在添加如下节点 <ANNEXURE_A> <ANNX_A/> </ANNEXURE_A> 但它正在抛出错误,该错误可能不包含“=”字符。如何实现这一点?您需要独立创建属性: For i = 1 To 10 Set nodChild = docXMLDOM.createElement("ANNX_A") nodChild.setAttribute "ID", i nodElement.appendChild n

下面是XML节点。我正在添加如下节点

<ANNEXURE_A>
<ANNX_A/>
</ANNEXURE_A>

但它正在抛出错误,该错误可能不包含“=”字符。如何实现这一点?

您需要独立创建属性:

For i = 1 To 10
    Set nodChild = docXMLDOM.createElement("ANNX_A")

    nodChild.setAttribute "ID", i

    nodElement.appendChild nodChild
Next i

好的,我明天就回来给你打电话,因为我要去旅行。不过看起来不错。谢谢
Set nodElement = docXMLDOM.createElement("ANNEXURE_A")
Set docXMLDOM.DocumentElement = nodElement
For i = 1 To 10
    Set nodChild = docXMLDOM.createElement("ANNX_A ID=" & """ & i & """)

    nodElement.appendChild nodChild
Next i
docXMLDOM.Save path

Set docXMLDOM = Nothing
For i = 1 To 10
    Set nodChild = docXMLDOM.createElement("ANNX_A")

    nodChild.setAttribute "ID", i

    nodElement.appendChild nodChild
Next i