Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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 VB和XML命名空间命名约定_Excel_Xml - Fatal编程技术网

Excel VB和XML命名空间命名约定

Excel VB和XML命名空间命名约定,excel,xml,Excel,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

假设在下面的示例中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信息集中没有属性顺序。

谢谢。运行我的代码,另一端的解析器似乎很好地接受了它