Looping Through An XML with VBA (Excel) -


i complete newbie xml string, hoping point me in right direction. including sample xml , code trying work with.

i able retrieve xml string , loop through it, must missing something, here want happen, starting @ order node loop through node , return basename , text, when reaches shipping address, need loop through node , results under child node? (basename , text) return first loop , continue getting rest of information.

many can provide, thank mike

here sample of xml:

<?xml version="1.0"?> <listordersresponse xmlns="https://mws.amazonservices.com/orders/2013-09-01">   <listordersresult>     <orders>       <order>         <latestshipdate>2015-10-29t06:59:59z</latestshipdate>         <ordertype>standardorder</ordertype>         <purchasedate>2015-10-25t04:04:33z</purchasedate>         <buyeremail>y73fy@marketplace.amazon.com</buyeremail>         <amazonorderid>258-7431234-5680250</amazonorderid>         <lastupdatedate>2015-10-26t14:35:02z</lastupdatedate>         <numberofitemsshipped>8</numberofitemsshipped>         <shipservicelevel>std cont street addr</shipservicelevel>         <orderstatus>shipped</orderstatus>         <saleschannel>amazon.com</saleschannel>         <shippedbyamazontfm>false</shippedbyamazontfm>         <isbusinessorder>false</isbusinessorder>         <latestdeliverydate>2015-11-05t07:59:59z</latestdeliverydate>         <numberofitemsunshipped>0</numberofitemsunshipped>         <buyername>john</buyername>         <earliestdeliverydate>2015-10-30t07:00:00z</earliestdeliverydate>         <ordertotal>           <currencycode>usd</currencycode>           <amount>7.35</amount>         </ordertotal>         <ispremiumorder>false</ispremiumorder>         <earliestshipdate>2015-10-27t07:00:00z</earliestshipdate>         <marketplaceid>atvpd212x0der</marketplaceid>         <fulfillmentchannel>mfn</fulfillmentchannel>         <paymentmethod>other</paymentmethod>         <shippingaddress>           <stateorregion>nj</stateorregion>           <city>north bergen</city>           <phone>5551234444</phone>           <countrycode>us</countrycode>           <postalcode>07047-7206</postalcode>           <name>john dd</name>           <addressline1>8100 toms rd apt 33</addressline1>         </shippingaddress>         <isprime>false</isprime>         <shipmentservicelevelcategory>standard</shipmentservicelevelcategory>         <sellerorderid>12345677</sellerorderid>       </order>       <order>         <latestshipdate>2015-10-29t06:59:59z</latestshipdate>         <ordertype>standardorder</ordertype>         <purchasedate>2015-10-25t05:05:14z</purchasedate>         <buyeremail>12345@marketplace.amazon.com</buyeremail>         <amazonorderid>123456789-7092245</amazonorderid>         <lastupdatedate>2015-10-26t14:35:02z</lastupdatedate>         <numberofitemsshipped>3</numberofitemsshipped>         <shipservicelevel>std cont street addr</shipservicelevel>         <orderstatus>shipped</orderstatus>         <saleschannel>amazon.com</saleschannel>         <shippedbyamazontfm>false</shippedbyamazontfm>         <isbusinessorder>false</isbusinessorder>         <latestdeliverydate>2015-11-05t07:59:59z</latestdeliverydate>         <numberofitemsunshipped>0</numberofitemsunshipped>         <buyername>can ss</buyername>         <earliestdeliverydate>2015-10-30t07:00:00z</earliestdeliverydate>         <ordertotal>           <currencycode>usd</currencycode>           <amount>3.35</amount>         </ordertotal>         <ispremiumorder>false</ispremiumorder>         <earliestshipdate>2015-10-27t07:00:00z</earliestshipdate>         <marketplaceid>atvpd212x0der</marketplaceid>         <fulfillmentchannel>mfn</fulfillmentchannel>         <paymentmethod>other</paymentmethod>         <shippingaddress>           <stateorregion>pa</stateorregion>           <city>king of prussia</city>           <phone>5552221234</phone>           <countrycode>us</countrycode>           <postalcode>19406-2462</postalcode>           <name>duo xu</name>           <addressline1>251 deb st apt 222</addressline1>         </shippingaddress>         <isprime>false</isprime>         <shipmentservicelevelcategory>standard</shipmentservicelevelcategory>         <sellerorderid>12345678</sellerorderid>       </order>     </orders>     <createdbefore>2015-10-26t15:12:55z</createdbefore>   </listordersresult>   <responsemetadata>     <requestid>123c1234-b12b-1c23-1234-1f23de00b123</requestid>   </responsemetadata> 

here code trying work with:

set list = xdoc.selectnodes("//order") set list2 = xdoc.selectnodes("//shippingaddress") x = 1 sheets(4).cells(x, 1) = strhtml  each node in list if (node.haschildnodes)     each childnode in node.childnodes         'debug.print childnode.basename & " " & childnode.text         sheets(2)             if childnode.basename = "shippingaddress"                 stop                 each node2 in list2                         stop                              if (node2.haschildnodes)                                 each childnode2 in node2.childnodes                                     .cells(x, 3) = childnode2.basename: .cells(x, 4) = childnode2.text                                     x = x + 1                                 next                             end if                             exit             next             else                 .cells(x, 1) = childnode.basename: .cells(x, 2) = childnode.text             end if              x = x + 1           end     next childnode end if next node 


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -