peskywinnets
Registered User.
- Local time
- Today, 18:25
- Joined
- Feb 4, 2014
- Messages
- 576
Disclaimer, I'm a kludger....I grab what I need & then lump the (often disparate) bits of code together to get the end result. I'll never be a programmer (I've got a business to run!)
Ok, with that said, this has been a long journey & I'm pretty much there, but I seek a more elegant way of taking some parsed XML & updating a table with the result.
Let's say I have a table called Orders with a column called OrderID. I parse some XML (taken from the web) & have some new information relating to that OrderID in my access database, let's say it OrderStatus....so I want to update 'OrderStatus' in my table with the contents of the XML.
Here's what I'm doing 9there's a lot of code prior to this, but it's not relevant to the question being asked)...
'rinse repeat
...essentially with each bit of parsed XML, I'm opening the table (to ensure the rst.FindFirst starts at the first record), then 'finding' the matched record, then updating the field of interest. It works fine, but - even to my non-programmer's eyes - it doesn't feel elegant.
Ok, with that said, this has been a long journey & I'm pretty much there, but I seek a more elegant way of taking some parsed XML & updating a table with the result.
Let's say I have a table called Orders with a column called OrderID. I parse some XML (taken from the web) & have some new information relating to that OrderID in my access database, let's say it OrderStatus....so I want to update 'OrderStatus' in my table with the contents of the XML.
Here's what I'm doing 9there's a lot of code prior to this, but it's not relevant to the question being asked)...
Code:
Set OrderCount = objxmldoc.selectNodes("//ns1:Order")
Set status = objxmldoc.selectNodes("//ns1:OrderStatus")
Set OrderId = objxmldoc.selectNodes("//ns1:OrderId")
R = 0
For Each node In OrderCount 'traverse through the XMl
Set rst = CurrentDb.OpenRecordset("SELECT * FROM Orders) ' I actually use a where statement to slim the number of selected records down, but removed here for simplicity
OrderID = OrderId(R).text 'parse the XML to find the first OrderID
OrderStatus = status(R).text 'parse the XML to get the Order status
rst.FindFirst "OrderID = 'OrderID'" ' find the OrderID in the Access table
rst.Edit
rst!OrderStatus = OrderStatus 'update the Access table with the latest status (as parsed from the XML)
rst.Update
rst.Close
R = R + 1
Next
...essentially with each bit of parsed XML, I'm opening the table (to ensure the rst.FindFirst starts at the first record), then 'finding' the matched record, then updating the field of interest. It works fine, but - even to my non-programmer's eyes - it doesn't feel elegant.
Last edited: