Hi,
I'm trying to read from xml files, and put values into variables to load to a database. I have been trying to work with the XML Dom, but have not had much luck.
I have the following xml:
<readin>
<doc>
<object id="1"/>
<object id="2"/>
<object id="3"/>
<object id="11"/>
<object id="12"/>
<object id="13"/>
<toperson>
<name/>
<attention>Bart Simpson</attention>
<city/>
</toperson>
</doc>
<doc>
<dres>
<object id="15"/>
</dres>
</doc>
</readin>
Basically I want to get the text value for each of the different elements. The <doc> is the main node
So I want to grab each object id from within the <doc> node, as well as the name, attention, etc.
Below is the code I have so far:
Dim objxml As MSXML2.DOMDocument60
Set objxml = New MSXML2.DOMDocument60
objxml.Load (strxmlname)
Dim oelem As IXMLDOMElement
Dim onode As IXMLDOMNode
Dim olist As IXMLDOMNodeList
Set objElem = objxml.documentElement
Set oList = objxml.selectNodes("doc")
For Each oelem In oList
look = oelem.getAttribute("object id")
Next oelem
When running this it the for each loop is completely as if there is no list under the doc node. Any help would be greatly appreciated.
I'm trying to read from xml files, and put values into variables to load to a database. I have been trying to work with the XML Dom, but have not had much luck.
I have the following xml:
<readin>
<doc>
<object id="1"/>
<object id="2"/>
<object id="3"/>
<object id="11"/>
<object id="12"/>
<object id="13"/>
<toperson>
<name/>
<attention>Bart Simpson</attention>
<city/>
</toperson>
</doc>
<doc>
<dres>
<object id="15"/>
</dres>
</doc>
</readin>
Basically I want to get the text value for each of the different elements. The <doc> is the main node
So I want to grab each object id from within the <doc> node, as well as the name, attention, etc.
Below is the code I have so far:
Dim objxml As MSXML2.DOMDocument60
Set objxml = New MSXML2.DOMDocument60
objxml.Load (strxmlname)
Dim oelem As IXMLDOMElement
Dim onode As IXMLDOMNode
Dim olist As IXMLDOMNodeList
Set objElem = objxml.documentElement
Set oList = objxml.selectNodes("doc")
For Each oelem In oList
look = oelem.getAttribute("object id")
Next oelem
When running this it the for each loop is completely as if there is no list under the doc node. Any help would be greatly appreciated.