473,747 Members | 2,736 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
  9.   objXMLDOM_patmls.async = False
  11. objXMLDOM_patmls.Load(App.path & "\xml\patMeals.xml")
  12.   Set rsPatMeals = CreateObject("ADODB.Recordset")
  13.   Set rsMeals = CreateObject("ADODB.Recordset")
  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 16724
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

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);
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...
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)...
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>
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...
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.
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);
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?
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...
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...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.