Hi,
It's me Mario!!
I have a Problem with adding Xml-Nodes.
Sometimes when I m adding XML-Nodes he is adding an Attribute xmlns, that cant be deleted.
But he isnt adding it all the time.
This is a part of the XML with added Nodes Highlighted:
The Red Nodes are the added ones and the bold attributes are the unwanted.
Maybe someone of you can tell me how to get rid of the attribute. i allready tried deleting it with [NodeName].removeAttribute("[AttrbuteName]")
best regards sascha
Edit: This is the code I m using for inserting:
EDIT: Solved: You have to add the same NameSpace as in the Head of the XML DOC:
Set Node = xDoc.createNode(NODE_ELEMENT,NodeName,"http://www.iec.ch/61850/2003/SCL")
It's me Mario!!
I have a Problem with adding Xml-Nodes.
Sometimes when I m adding XML-Nodes he is adding an Attribute xmlns, that cant be deleted.
But he isnt adding it all the time.
This is a part of the XML with added Nodes Highlighted:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.iec.ch/61850/2003/SCL SCL.xsd" version="2007" revision="B">
<Private type="Siemens-DIGSI5ExportComment"></Private>
<Header id="Goose-Test" revision="1" version="4" toolID="DIGSI 5 V3.0">
<History>
<Hitem version="1" revision="1" what="Exported as Siprotec_7SL87_ohne.cid." when="Tuesday, August 27, 2013, 9:13:24 AM" why="Exported as Siprotec_7SL87_ohne.cid."/>
<Hitem version="2" revision="1" what="File GOOSE_Siprotec_7SL87_ohne.cid imported." when="Tuesday, August 27, 2013, 9:30:32 AM" why="File GOOSE_Siprotec_7SL87_ohne.cid imported."/>
<Hitem version="3" revision="1" what="Exported as Siprotec_7SL87_mit_GOOSE.cid." when="Tuesday, August 27, 2013, 9:35:36 AM" why="Exported as Siprotec_7SL87_mit_GOOSE.cid."/>
<Hitem version="4" revision="1" what="Exported as Siprotec_7SL87_ohne.cid." when="Tuesday, August 27, 2013, 9:36:48 AM" why="Exported as Siprotec_7SL87_ohne.cid."/>
</History>
</Header>
<Communication>
<SubNetwork name="Default_subnet">
<Private type="Siemens-MasterId">57565446668289</Private>
<Private xmlns="" type="Siemens-Application">GOOSE application||0001||PriorityLow||10|2000|000|4</Private>
<ConnectedAP iedName="SIP" apName="F">
<Private xmlns="" type="Siemens-Application-GSEControl">GOOSE application|Ln1_21DistanceProt1|Control_Dataset</Private>
<Address>
<P type="IP" xsi:type="tP_IP">10.16.60.60</P>
<P type="IP-SUBNET" xsi:type="tP_IP-SUBNET">255.255.255.0</P>
<P type="OSI-AP-Title">1,3,9999,23</P>
<P type="OSI-AE-Qualifier">23</P>
<P type="OSI-PSEL">00000001</P>
<P type="OSI-SSEL">0001</P>
<P type="OSI-TSEL">0001</P>
</Address>
<GSE xmlns="" ldInst="Ln1_21DistanceProt1" cbName="Control_Dataset">
<Address>
<P type="VLAN-ID" xsi:type="tP_VLAN-ID">000</P>
<P type="VLAN-PRIORITY" xsi:type="tP_VLAN-PRIORITY">4</P>
<P type="MAC-Address" xsi:type="tP_MAC-Address">01-0C-CD-01-00-00</P>
<P type="APPID" xsi:type="tP_APPID">0001</P>
</Address>
<MinTime unit="s" multiplier="m">10</MinTime>
<MaxTime unit="s" multiplier="m">1000</MaxTime>
</GSE>
Maybe someone of you can tell me how to get rid of the attribute. i allready tried deleting it with [NodeName].removeAttribute("[AttrbuteName]")
best regards sascha
Edit: This is the code I m using for inserting:
Code:
Private Function AddNode(Insert As Boolean, xDoc As DOMDocument, ParentNode As IXMLDOMElement, NodeName As String,Last As Boolean, Optional cNode As Integer) As MSXML2.IXMLDOMElement
Dim Node As MSXML2.IXMLDOMNode
Dim Spaces As String
Dim SpacesTotal As String
Dim CountNode As MSXML2.IXMLDOMElement
Dim Root As MSXML2.IXMLDOMElement
Dim level As Integer
Set CountNode = ParentNode
Set Root = xDoc.selectSingleNode("//SCL")
level = 0
Spaces = " "
SpacesTotal = ""
Do
Set CountNode = CountNode.parentNode
level = level + 1
Loop Until CountNode.nodeName = Root.nodeName
'Add the node to the document
Set Node = xDoc.createNode(NODE_ELEMENT,NodeName,"")
If Insert = True Then
Set AddNode = ParentNode.insertBefore(Node,ParentNode.childNodes.Item(cNode))
ParentNode.insertBefore(xDoc.createTextNode(vbNewLine),Node)
ParentNode.insertBefore(xDoc.createTextNode(vbNewLine),Node.nextSibling)
For i = 0 To level
ParentNode.insertBefore(xDoc.createTextNode(Spaces),Node)
ParentNode.insertBefore(xDoc.createTextNode(Spaces),Node.nextSibling.nextSibling)
Next
Else
ParentNode.appendChild(xDoc.createTextNode(vbNewLine))
For i = 0 To level
ParentNode.appendChild(xDoc.createTextNode(Spaces))
Next
Set AddNode = ParentNode.appendChild(Node)
If Last = True Then
For i = 0 To level-1
SpacesTotal = SpacesTotal & Spaces
Next
ParentNode.appendChild(xDoc.createTextNode(vbNewLine & SpacesTotal))
End If
End If
Set AddNode = Node
Set Node = Nothing
End Function
Set Node = xDoc.createNode(NODE_ELEMENT,NodeName,"http://www.iec.ch/61850/2003/SCL")