Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

VBA - XML how to remove node and copy a node from other xml file and save

Avatar of vrajvilas
vrajvilas asked on
Programming Languages-OtherVisual Basic Classic
15 Comments1 Solution6615 ViewsLast Modified:
Hi all,
  i am new to xml parsing in vba, attached is the xml where i have to remove a node called <Symbology> </Symbology> where the feature name is (<feature name="O_Signal_Structure">)
O_Signal_Structure and copy the node <Symbology> </Symbology>  for the same feature name from another xml file which has the same structrue as the one attached and save the xml file.

i could only get this far and had problem removing the node, please see code below for reference

Public oXMLDocument As DOMDocument60
Public oXMLNode As IXMLDOMNode
Public oXMLElement As IXMLDOMElement
Public oXMLNodeList As IXMLDOMNodeList

Public oXMLNodesData As IXMLDOMElement
Public oXMLSubElement As IXMLDOMElement
Public oXMLSubChildElement As IXMLDOMElement
Public oXMLSubChildElement1 As IXMLDOMElement

Public Sub testXml()

Set oXMLDocument = New DOMDocument60
    oXMLDocument.async = False
    oXMLDocument.Load ("C:\Dev\BMAP Data\depot_own.xml")

    Set oXMLNodesData = oXMLDocument.documentElement()
    Set oXMLNodeList = oXMLNodesData.selectNodes("Workspace")
    For Each oXMLElement In oXMLNodeList
       MsgBox oXMLElement.nodeName
       MsgBox oXMLElement.Text  
        For Each oXMLSubElement In oXMLElement.childNodes
            MsgBox oXMLSubElement.nodeName  
            MsgBox oXMLSubElement.Text              
          For Each oXMLSubChildElement In oXMLSubElement.childNodes
             MsgBox oXMLSubChildElement.nodeName  
             MsgBox oXMLSubChildElement.Text            
             For Each oXMLSubChildElement1 In oXMLSubChildElement.childNodes
                MsgBox oXMLSubChildElement1.nodeName  
                MsgBox oXMLSubChildElement1.Text
                If oXMLSubChildElement1.nodeName = "Symbology" Then
                --------- how to remove the node symbology and insert the symbology node from another xml file--------------------------------------------------------------------------
                End If

End Sub

Appreciate your response


<?xml version="1.0" encoding="utf-16"?>
<GeospatialSchema projectName="test">
 <Workspace name="All Users">
   <Features genFile="features.xml">
      <feature name="O_Signal_Structure" alias="O Signal Structure">
	<Symbology type="cell">
          <OverrideScale />
          <property name="Accuracy_C" alias="Accuracy C" >
            <initialValue key="placing" synch="true" valueType="value" />
            <dataSpec numChars="5" min="" minExclusive="false" max="" maxExclusive="false" />			  </property>
	<feature name="O_Signal_Structure_Line" alias="O Signal Structure Line">
	<Symbology type="linear">
          <OverrideScale />
          <Color red="-1" green="-1" blue="-1">20</Color>
          <property name="Accuracy_C" alias="Accuracy C" >
            <initialValue key="placing" synch="true" valueType="value" />
            <dataSpec numChars="5" min="" minExclusive="false" max="" maxExclusive="false" />			  </property>
Avatar of needtoken
needtokenFlag of India image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 15 Comments.
See Answers