473,769 Members | 3,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB6 - Looping thru XML elements into rs using MSXML2.DOMDocum ent40

3 New Member
Hi everyone,

I'm a newbie to the forum.

I have an issue and was hoping to get some assistance/ideas:

Im trying to read a XML file into two record sets.
I can acheive looping through the first level element but i can not loop the the second level (child elements), any ideas??
I need to be able to loop thru each patient record and read into rsPatMeals and secondly loop thru each <meal_selecte d> and read into rsMeals.
---- xml file---
Expand|Select|Wrap|Line Numbers
  1. <Hospital>    
  2.     <PATIENT>        
  3.         <ur>ppp</ur>        
  4.         <area>Wards</area>        
  5.         <meal_selected>            
  6.             <menuno>67</menuno>                    <mod1>4</mod1>            
  7.             <mod2>12</mod2>        
  8.         </meal_selected>        
  9.         <meal_selected>            
  10.             <menuno>13</menuno>                    <mod1>1</mod1>            
  11.             <mod2>0</mod2>        
  12.         </meal_selected>        
  13.         <meal_selected>            
  14.             <menuno>120</menuno>                    <mod1>0</mod1>            
  15.             <mod2>0</mod2>        
  16.         </meal_selected>        
  17.         <meal_selected>            
  18.             <menuno>124</menuno>                    <mod1>9</mod1>            
  19.             <mod2>0</mod2>        
  20.         </meal_selected>    
  21.     </PATIENT>    
  22.     <PATIENT>        
  23.         <ur>mmm</ur>        
  24.         <area>Wards</area>        
  25.         <meal_selected>            
  26.             <menuno>7</menuno>                    <mod1>0</mod1>            
  27.             <mod2>0</mod2>        
  28.         </meal_selected>        
  29.         <meal_selected>            
  30.             <menuno>22</menuno>                    <mod1>19</mod1>            
  31.             <mod2>0</mod2>        
  32.         </meal_selected>        
  33.         <meal_selected>            
  34.             <menuno>86</menuno>                    <mod1>0</mod1>            
  35.             <mod2>0</mod2>        
  36.         </meal_selected>        
  37.         <meal_selected>            
  38.             <menuno>153</menuno>                    <mod1>0</mod1>            
  39.             <mod2>16</mod2>        
  40.         </meal_selected>    
  41.     </PATIENT>
  42. </Hospital>
---------------------------------------------------------------------
---VB 6 Code----
Expand|Select|Wrap|Line Numbers
  1.   Dim objXMLDOM_patmls As New MSXML2.DOMDocument40
  2.   Dim objPatNodesList As IXMLDOMNodeList
  3.   Dim objPatientNode As IXMLDOMNode
  4.   Dim objMealNodes As IXMLDOMNodeList
  5.   Dim rsPatMeals As New ADODB.Recordset
  6.   Dim rsMeals As New ADODB.Recordset
  7.   Dim pstrSQL As String
  8.  
  9.   objXMLDOM_patmls.async = False
  10.  
  11. objXMLDOM_patmls.Load(App.path & "\xml\patMeals.xml")
  12.   Set rsPatMeals = CreateObject("ADODB.Recordset")
  13.   Set rsMeals = CreateObject("ADODB.Recordset")
  14.  
  15.   Set objPatNodesList =_
  16.  objXMLDOM_patmls.selectNodes("Hospital/PATIENT")
  17.   Set objMealNodes =_  objXMLDOM_patmls.selectNodes"Hospital/PATIENT/meal_selected")
  18.   For Each objPatientNode In objPatNodesList
  19.           rsPatMeals.AddNew
  20.           rsPatMeals.Fields("UR") = objPatientNode.selectSingleNode("ur").nodeTypedValue
  21.           rsPatMeals.Fields("AREA") = objPatientNode.selectSingleNode("area").nodeTypedValue
  22.           rsPatMeals.Fields("WARD") = objPatientNode.selectSingleNode("ward").nodeTypedValue
  23.           rsPatMeals.Fields("BED") = objPatientNode.selectSingleNode("bed").nodeTypedValue
  24.           rsPatMeals.Fields("CYCLE") = objPatientNode.selectSingleNode("cycle").nodeTypedValue
  25.           rsPatMeals.Fields("DOW") = objPatientNode.selectSingleNode("dow").nodeTypedValue
  26.           rsPatMeals.Fields("MLDATE") = objPatientNode.selectSingleNode("mldate").nodeTypedValue
  27.           rsPatMeals.Fields("MEALMODS") = objPatientNode.selectSingleNode("mealmods").nodeTypedValue
  28.           rsPatMeals.Fields("DISCHARGED") = 0  'current ur to be checked against pmi to determin
  29.           rsPatMeals.Fields("SOURCE") = objPatientNode.selectSingleNode("source").nodeTypedValue
  30.           rsPatMeals.Fields("FMSUSER") = "PDS"
  31.           rsPatMeals.Fields("FMSUSERUPDATE") = Now()
  32.           rsPatMeals.Update
  33.   Next objPatientNode
Does anyone have any ideas on how i can loop thru all <meal_selecte d> for each <patient> and assign to the rsMeals ??

Any help would be greatly appreciated
May 11 '07 #1
1 16728
pds79
3 New Member
The FOR loop should look like:
Expand|Select|Wrap|Line Numbers
  1. For Each objPatientNode In objPatNodesList
  2.   rsPatMeals.AddNew
  3.   rsPatMeals.Fields("UR") = objPatientNode.selectSingleNode("ur").nodeTypedValue
  4.   rsPatMeals.Fields("AREA") = objPatientNode.selectSingleNode("area").nodeTypedValue
  5.   rsPatMeals.Update
  6. Next objPatientNode
May 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1835
by: cppaddict | last post by:
Hi, I need to a way to loop thru vectors (or some other appropriate collection type) using constructs such as: for (pr = someVector.begin(); pr != someVector.end(); pr++) SomeFunction(*pr);
12
6083
by: Mark Constant | last post by:
I have a drop-down list now and I got it so when something is selected from the drop down list it calls a JavaScript function. I want it so the value selected from the drop-down list is sent as a parameter to the xslt file. When I select a value from the drop-down list nothing appears. I want just a basic listing of Title, Image, and Description outputed. I have done a basic JavaScript that uses the .write() function and that worked so the...
1
1983
by: wooks | last post by:
I have some information embedded in included schemas which I want to access at run-time for the purposes of contructing a GUI (they will support field labels and tool tips). The options seem to be to store them as documentation/appinfo elements within the included schema or as unhandled attributes. Because the schemas are included it seems the items would have to be accessed via the SOM (as opposed to retrieving the details via XPATH)...
1
5008
by: bird | last post by:
?sitem <?xml version="1.0"?> <RootNode> ' one root node <Transaction> ' doc element node <AccountNumber>1001000</AccountNumber> ' node list/children <Amount>100.00</Amount> </Transaction> </RootNode>
1
8123
by: Shaileen Patel | last post by:
Hi, I am trying to convert a lot of web reports from ASP/VB to ASP.NET/VB.NET. I would like to save my dataset in XML and then use XSLT to transform the XML. The catch is I would like to have the XML in the format that ADO uses versus the default format in which ADO.NET uses. Currently, I am using ADO within .NET, but I am concerned about the performance and it might improve if I used the native data providers for .NET. I am not sure if...
2
16093
by: pob | last post by:
Whats the difference between using a control or a listbox when looping thru a listbox. In example 1 it dims a listbox and an example 2 it dims a control. Please explain. Thanks in advance Example 1 from Allen Browne MVP Access To use a Multiselect list box for criteria for a report, you need to loop through its ItemsSelected collection to create a string that can act as the WhereCondition for your report.
16
2521
by: kaferro | last post by:
What is the typical way to loop through a vector while deleting certain elements during the loop process? The code below works, but I am wondering if there is a better solution. vector<intvTmp; vTmp.push_back(1); vTmp.push_back(2); vTmp.push_back(1); vTmp.push_back(2);
1
1522
by: PedroVision | last post by:
Greetings All... When I try to debug my .Net program...I get the following 2 errors... Error 1 Type 'Msxml2.DOMDocument40' is not defined. Error 2 Type 'IXMLDOMNode' is not defined. I think I need to do an "Import"...but I don't know what to import! Anyone have any suggestions?
6
2734
by: mahowe | last post by:
Hi, I have had this problem for a while and have not been able solve it. What im looking at doing is looping thru my patient table and trying to organise the patients in to there admission sequence, so when patient "A" comes in and is treated at my hospital and is discharged and admitted to another Hospital within one day then patient "A" will get a code of 1 being there first admission. then if patient "A" is admitted again but there...
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9851
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7403
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.