Click here to Skip to main content
15,891,431 members
Home / Discussions / C#
   

C#

 
QuestionLooping through XMLNodeList problem Pin
jamesc6910-Jan-10 23:32
jamesc6910-Jan-10 23:32 
AnswerRe: Looping through XMLNodeList problem Pin
Keith Barrow11-Jan-10 0:00
professionalKeith Barrow11-Jan-10 0:00 
GeneralRe: Looping through XMLNodeList problem Pin
jamesc6911-Jan-10 0:05
jamesc6911-Jan-10 0:05 
GeneralRe: Looping through XMLNodeList problem [modified] Pin
Keith Barrow11-Jan-10 0:11
professionalKeith Barrow11-Jan-10 0:11 
GeneralRe: Looping through XMLNodeList problem Pin
jamesc6911-Jan-10 0:23
jamesc6911-Jan-10 0:23 
GeneralRe: Looping through XMLNodeList problem Pin
Luc Pattyn11-Jan-10 0:47
sitebuilderLuc Pattyn11-Jan-10 0:47 
GeneralRe: Looping through XMLNodeList problem Pin
Keith Barrow11-Jan-10 0:54
professionalKeith Barrow11-Jan-10 0:54 
GeneralRe: Looping through XMLNodeList problem Pin
jamesc6911-Jan-10 1:08
jamesc6911-Jan-10 1:08 
Here is a complete XML snapshot:

<?xml version="1.0" encoding="utf-8">;
<HotelAvail xmlns="http://www.transhotel.com/transHotel/2004A"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.transhotel.com/transHotel/2004A HotelAvailRQ.xsd">
   <WholesalerID&gt;TRANSHOTEL&lt;/WholesalerID>
   <Hotels>
      <HotelCode&gt;1154718&lt;/HotelCode>
   </Hotels>
   <Dates>
      <CheckIn>2010-01-21</CheckIn>
      <CheckOut>2010-01-22</CheckOut>
   </Dates>
   <Rooms>
      <Room>
         <RoomRQId>1</RoomRQId>
         <Quantity>1</Quantity>
         <NumAdults>3</NumAdults>
      </Room>
      <Room>
         <RoomRQId>2</RoomRQId>
         <Quantity>1</Quantity>
         <NumAdults>2</NumAdults>
      </Room>
   </Rooms>
</HotelAvail>

If I run in debug mode, on the first pass through ForEach it says that the innertext will be 113 (for the whole occurrence of that node), on the second pass it says that the innertext will be 212 (which is correct).   So the problem has got to be how the variables are set from the referenced nodes.   For some reason it is selecting the 1st occurence of each element within Room even though it is running within a loop.   I know this can be a problem with say SelectSingleNode, but I'm not using that.   So therefore objRNode["RoomRQId"].InnerText is not iterative, and is always picking the 1st occurence with the document.
A namespace is used and referenced as follows:
XmlNamespaceManager ns = new XmlNamespaceManager(xmlDoc.NameTable);
                  ns.AddNamespace("test", "http://www.transhotel.com/transHotel/2004A");
There is only one "Rooms" node, so that is selected explicitly so as to ensure no confusion.   Objwriter is an XMLTextWriter which is merely writing the output.
GeneralRe: Looping through XMLNodeList problem Pin
Keith Barrow11-Jan-10 1:35
professionalKeith Barrow11-Jan-10 1:35 
GeneralRe: Looping through XMLNodeList problem Pin
Luc Pattyn11-Jan-10 2:09
sitebuilderLuc Pattyn11-Jan-10 2:09 
GeneralRe: Looping through XMLNodeList problem Pin
Keith Barrow11-Jan-10 2:23
professionalKeith Barrow11-Jan-10 2:23 
GeneralRe: Looping through XMLNodeList problem Pin
jamesc6911-Jan-10 2:33
jamesc6911-Jan-10 2:33 
GeneralRe: Looping through XMLNodeList problem Pin
Keith Barrow11-Jan-10 3:00
professionalKeith Barrow11-Jan-10 3:00 
AnswerRe: Looping through XMLNodeList problem Pin
#realJSOP11-Jan-10 3:31
mve#realJSOP11-Jan-10 3:31 
QuestionHow do I get the location and size of the upper leftmost cell in a DataGridView? Pin
arnold_w10-Jan-10 22:25
arnold_w10-Jan-10 22:25 
AnswerRe: How do I get the location and size of the upper leftmost cell in a DataGridView? Pin
sanforjackass10-Jan-10 23:55
sanforjackass10-Jan-10 23:55 
GeneralRe: How do I get the location and size of the upper leftmost cell in a DataGridView? Pin
arnold_w11-Jan-10 0:02
arnold_w11-Jan-10 0:02 
Questionappending text Pin
Member 59031010-Jan-10 22:23
Member 59031010-Jan-10 22:23 
AnswerRe: appending text Pin
Nicholas Butler10-Jan-10 22:27
sitebuilderNicholas Butler10-Jan-10 22:27 
AnswerRe: appending text Pin
Abhinav S10-Jan-10 22:59
Abhinav S10-Jan-10 22:59 
QuestionCant Write Large Text File Pin
salamonty8610-Jan-10 21:49
salamonty8610-Jan-10 21:49 
AnswerRe: Cant Write Large Text File Pin
Covean10-Jan-10 22:13
Covean10-Jan-10 22:13 
GeneralRe: Cant Write Large Text File Pin
salamonty8611-Jan-10 0:27
salamonty8611-Jan-10 0:27 
GeneralRe: Cant Write Large Text File Pin
Covean11-Jan-10 1:19
Covean11-Jan-10 1:19 
QuestionMaking a maths solver Pin
Matt Cavanagh10-Jan-10 21:37
Matt Cavanagh10-Jan-10 21:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.