[英]Checking for XML declaration in VB6
Firstly apologies...I haven't used VB6 (or any strain of VB for that matter) for a very long time. 首先,道歉...我已经很长时间没有使用VB6了(或者任何VB菌株)。
I had the following code 我有以下代码
nodRoot.appendChild TempTableData.childNodes(0)
That gives the error "This operation can not be performed with a Node of type XMLDECL." 出现错误“无法使用XMLDECL类型的节点执行此操作”。
So I loop through the Child nodes as follows to not append the node if it is the XML declaration. 因此,我按如下所示遍历Child节点,以不追加该节点(如果它是XML声明)。
Dim nod As IXMLDOMNode
For Each nod In TempTableData.childNodes()
If Not nod.baseName = "xml" Then
nodRoot.appendChild nod
End If
Next nod
Which works ok but seems an inelegant way of checking for an XML Node declaration. 可行,但似乎是检查XML Node声明的一种巧妙方法。 So what I'd like to achieve is to check against node type = XMLDECL but I can't find a way of doing this.
因此,我想实现的是检查节点类型= XMLDECL,但我找不到解决方法。
Cheers. 干杯。
Like you I'm dredging the depths of ancient memory, but I have a vague recollection that in the COM XML implementations, the XML Declaration node had nodeType = NODE_PROCESSING_INSTRUCTION (= 7)
. 像您一样,我正在挖掘古代内存的深度,但是我有一个模糊的回忆,在COM XML实现中,XML声明节点具有
nodeType = NODE_PROCESSING_INSTRUCTION (= 7)
。
So if removing all processing instructions is OK you could filter on that, otherwise you'll still have to check the baseName, so you don't gain anything. 因此,如果删除所有处理指令是可以的,则可以对此进行过滤,否则,您仍然必须检查baseName,因此不会获得任何收益。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.