excel - extract multiple xml nodes into array without looping -
i have xml doc looks this:
<rng> <col1> <row1>a</row1> <row2>b</row2> <row3>c</row3> <row4>d</row4> </col1> <col2> <row1>e</row1> <row2>f</row2> <row3>g</row3> <row4>h</row4> </col2> </rng>
there lot more of col nodes, , each 1 contains several thousand row elements.
i'd parse out values row elements , put them onto spreadsheet. i'm doing follows:
' list of col elements (thi sits in loop go through them all) set oxmlcolnodelist = oxmldoc.selectnodes("//savestates/rng/*") ' lop through each column colnum = 1 oxmlcolnodelist.length ' row nodes coulmn set oxmlrownodelist = oxmldoc.selectnodes("//savestates/rng"/col" & colnum & "/*") ' loop through row nodes rownum = 1 oxmlrownodelist.length ' node set oxmlnode = oxmldoc.selectsinglenode("//savestates/rng/col" & colnum & "/row" & rownum) next rownum next colnum
i.e. i'm looping through col nodes, through each of row nodes values a, b, c, d etc. it's catastrophically slow when number of row elements goes towards tens of thousands.
i don't have experience parsing xml docs, i'm looking way extract values 'row*' nodes @ same time, without having loop through them. possible?
maybe can use ado db recordset open xml dom document in recordset, use range.copyfromrecordset method dump data excel after adding filter records want?
here sample code msdn: how obtain recordset xml
public function recordsetfromxmldocument(xmldomdocument domdocument) recordset dim orecordset adodb.recordset dim destrange range set destrange=range("b2") set orecordset = new adodb.recordset orecordset.open xmldomdocument 'pass dom document instance source argument set recordsetfromxmldocument = orecordset 'return recordset destrange.copyfromrecordset orecordset set orecordset = nothing end function