excel - Excel VB 和 XML 命名空间命名约定
问题描述
假设 gfx 是以下示例中的根元素,xmlns:xsi 和 xsi:noNameSpaceSchemaLocation 是否被视为根的属性,如果是,如何使用 Excel VB 语法分配它们?使用下面的代码,它们出现的顺序是相反的
Dim doc As New MSXML2.DOMDocument60
Dim root As IXMLDOMElement
Dim rootAttrib1 As IXMLDOMAttribute, rootAttrib2 As IXMLDOMAttribute
' DECLARE ROOT AND CHILDREN '
Set root = doc.createElement("gfx")
doc.appendChild root
Set rootAttrib1 = doc.createAttribute("xmlns:xsi")
rootAttrib1.Value = "http://www.w3.org/2001/XMLSchema-instance"
root.setAttributeNode rootAttrib1
Set rootAttrib2 = doc.createAttribute("xsi:noNamespaceSchemaLocation")
rootAttrib2.Value = "Gfx-ME12.xsd"
root.setAttributeNode rootAttrib2
期望的输出
<?xml version="1.0" encoding="UTF-8"?>
<gfx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Gfx-ME12.xsd">
实际输出
<?xml version="1.0" encoding="UTF-8"?>
<gfx xsi:noNamespaceSchemaLocation="Gfx-ME12.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
解决方案
xml 属性的顺序无关紧要。在 xml 信息集中,没有属性顺序之类的东西。
推荐阅读
- angular - 如何将新数据附加到存储在 firebase 的 firestore 上的数组中?节点,Ionic3,角度,Javascript
- python - 存储函数的参数以供以后评估
- r - 在 r 中创建特殊的子组列
- c# - 无法访问文件夹名称末尾有多个连续空格的文件
- azure-data-factory - REST 成功,Azure 数据工厂中的 HTTP 失败,但需要证书
- html - 如何保护托管在 Github 页面上的 html 文件中的机密?
- simulation - 具有二元变量和调节中介的 Lavaan 模型
- gcc - 使用静态库构建 HA 代理 - 库优先级
- reactjs - axios中的第一个请求没有取回数据
- excel - Excel宏VBA在先前添加的行下方添加行,并复制格式和公式