M
mister tbo
Hello,
Calling out for help... I've been searching and still clueless about this
one...
I'm trying to load an XML file, append data to it, then save it.
The following bit of a code is a test routine which illustrates my problem :
VBA Module :
_________________________
"Option Base 1
Sub xmlDomManipulation()
Dim xmlDoc As DOMDocument, root As IXMLDOMElement
Set xmlDoc = New DOMDocument
xmlDoc.async = False
xmlDoc.Load (ThisWorkbook.Path & "\Bookstore.xml")
Set root = xmlDoc.documentElement
ReDim xmlYear(root.childNodes.Length) As IXMLDOMNode
For i = 1 To root.childNodes.Length
Set xmlYear(i) = root.childNodes.Item(1)
ReDim xmlMonth(i, xmlYear(i).childNodes.Length) As IXMLDOMNode
For j = 1 To xmlYear(i).childNodes.Length
Set xmlMonth(i, j) = xmlYear(i).childNodes.Item(j)
Next j
Next i
End Sub"
XML File :
________________________
<?xml version="1.0"?>
<data>
<year y="2007" passed="1">
<month m="1">
<day d="01" ca="3497" pax="57"/>
<day d="02" ca="5487" pax="73"/>
<day d="03" ca="3256" pax="40"/>
</month>
</year>
<year y="2008" passed="0">
<month m="1">
<day d="01" ca="3497" pax="57"/>
<day d="02" ca="5487" pax="73"/>
<day d="03" ca="3256" pax="40"/>
</month>
</year>
</data>
When I check the results of this routine via locals windows, I see that
xmlYear(i) is loaded correctly as an IXMLDOMNode, but xmlMonth(i, j) is set
as nothing....
Any clues to the how and the why of this would be welcome...
Cheers.
Calling out for help... I've been searching and still clueless about this
one...
I'm trying to load an XML file, append data to it, then save it.
The following bit of a code is a test routine which illustrates my problem :
VBA Module :
_________________________
"Option Base 1
Sub xmlDomManipulation()
Dim xmlDoc As DOMDocument, root As IXMLDOMElement
Set xmlDoc = New DOMDocument
xmlDoc.async = False
xmlDoc.Load (ThisWorkbook.Path & "\Bookstore.xml")
Set root = xmlDoc.documentElement
ReDim xmlYear(root.childNodes.Length) As IXMLDOMNode
For i = 1 To root.childNodes.Length
Set xmlYear(i) = root.childNodes.Item(1)
ReDim xmlMonth(i, xmlYear(i).childNodes.Length) As IXMLDOMNode
For j = 1 To xmlYear(i).childNodes.Length
Set xmlMonth(i, j) = xmlYear(i).childNodes.Item(j)
Next j
Next i
End Sub"
XML File :
________________________
<?xml version="1.0"?>
<data>
<year y="2007" passed="1">
<month m="1">
<day d="01" ca="3497" pax="57"/>
<day d="02" ca="5487" pax="73"/>
<day d="03" ca="3256" pax="40"/>
</month>
</year>
<year y="2008" passed="0">
<month m="1">
<day d="01" ca="3497" pax="57"/>
<day d="02" ca="5487" pax="73"/>
<day d="03" ca="3256" pax="40"/>
</month>
</year>
</data>
When I check the results of this routine via locals windows, I see that
xmlYear(i) is loaded correctly as an IXMLDOMNode, but xmlMonth(i, j) is set
as nothing....
Any clues to the how and the why of this would be welcome...
Cheers.