xmlnode question

Hello,
I'm new to xml and I have a question:

I try to do the following
Dim doc As New XmlDocument
doc.LoadXml("<Request><Root><Requestor name='' /><FlowData flowstatus='' 
/><Products><productdate productid='' /></Products></Root></Request>")

        Dim node As XmlNode = 
doc.SelectSingleNode("Request/Root/Requestor/@name")

        node.Value = "TestValue"
        Dim node3 As XmlNode = 
doc.SelectSingleNode("Request/Root/FlowData/@flowstatus")

        node3.Value = "TestStatus"

'here comes something I don't know how to do, I want to fill in multiple 
products

        Dim i As Integer = 1
        Dim node2 As XmlNode
        For i = 1 To 3

            node2 = 
doc.SelectSingleNode("Request/Root/Products/productdate/@productid")
            node2.Value = i

            i = i + 1
        Next i


Finally I take the innerxml to do further operations.

The problem is that the value for node2 always get overwritten. I want a 
loop that fills x number of products.

Any suggestions ?

Regards, 


0
10/12/2006 3:19:57 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
696 Views

Similar Articles

[PageSpeed] 40


NS wrote:


> Dim doc As New XmlDocument
> doc.LoadXml("<Request><Root><Requestor name='' /><FlowData flowstatus='' 
> /><Products><productdate productid='' /></Products></Root></Request>")

>         Dim i As Integer = 1
>         Dim node2 As XmlNode
>         For i = 1 To 3
> 
>             node2 = 
> doc.SelectSingleNode("Request/Root/Products/productdate/@productid")
>             node2.Value = i
> 
>             i = i + 1
>         Next i


> The problem is that the value for node2 always get overwritten. I want a 
> loop that fills x number of products.

Well your XML above does not have several products elements but only one 
and only once productdate element. If you want to add elements to an 
XmlDocument then you need to first create them and then insert as needed 
e.g.
   Dim Products As XmlNode = doc.SelectSingleNode("Request/Root/Products")
   For I = 2 To 3
     Dim ProductDate As XmlElement = doc.CreateElement("productdate")
     ProductDate.SetAttribute("productid", I.ToString())
     Products.AppendChild(ProductDate)
   Next

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
10/12/2006 3:31:14 PM
"Martin Honnen" <mahotrash@yahoo.de> schreef in bericht 
news:uHWv3Nh7GHA.3644@TK2MSFTNGP03.phx.gbl...
>
> > Well your XML above does not have several products elements but only one
> and only once productdate element. If you want to add elements to an 
> XmlDocument then you need to first create them and then insert as needed 
> e.g.
>   Dim Products As XmlNode = doc.SelectSingleNode("Request/Root/Products")
>   For I = 2 To 3
>     Dim ProductDate As XmlElement = doc.CreateElement("productdate")
>     ProductDate.SetAttribute("productid", I.ToString())
>     Products.AppendChild(ProductDate)
>   Next
>
> -- 
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/

Thank you very much ! Do you have any tips suggestions to read my 
xmldocument into a dataset ?
Dim doc As New XmlDocument
doc.LoadXml("<Request><Root><Requestor name='' /><FlowData flowstatus=''
/><Products><productdate productid='' /></Products></Root></Request>")


Or any other suggestions so that I can manipulate data ?
e.g. I want to build a webform with a detail table with all the products 
from my xmldocument.

Regards,
NS 


0
10/13/2006 9:10:03 AM
Reply:

Similar Artilces:

Beginners Question
I know how to add two cells but I would like the cells to have a title within the cell. Something like 8.5 Hrs, or 32 steaks. Something like that. -- Thank you in Advance Hi Format>Cells>Number>Custom> #.0 "Hrs" or General "Steaks The part before the text can be formatted in any of the standard number formats. It will appear as 32 Steaks, but all that will be held in the cell is 32, which can then be used in further calculations if required. -- Regards Roger Govier "GordyB" <GordyB@discussions.microsoft.com> wrote in mess...

XmlNode
When an XmlNode method returns an XmlNode, such as a child, is this generated on-the-fly or is it the actual component of the internal tree structure? If the parent is moved in the tree, will the pointer remain valid? I have looked at as much of the structure as I can using .NET Reflector and I think it will, but I want to be sure. I 'm planning to add XmlNodes to the Tag property of TreeNodes in a TreeView to be able to persist changes back to the document and I would like to know if this will take up any more memory than when they are not linked in this way, or if it is better to...

SBS 2003 to SBS 2008 question
dear all, I am a consultant and working home where I have a single SBS 2003 server and a normal ADSL router. I have 2 client pc connected to my single SBS 2003. I would like to learn how to install SBS 2008. For that I am running my SBS install in a VM ware virtual machine but I do not want that that VM istallation corrupt somehow my existing network installation manage by my running SBS 2003. My server sbs 2003 is set as follow : IP : 192.168.1.102 Msk:255.255.255.0 Gateway :192.168.1.1 ( my adsl router) then my client PC are receiving IP adress from my sbs server. C...

Calendar Question #3
Does anyone know if you should be able to see appointments in your calendar before accepting them. I have a client who believes this used to work for him and now it does not. After coming back from a week of travelling, he would just go into his calendar and accept meetings from there. Is this possible? Derek Rumig Sorry, connects to an Exchange 2000 server. "Derek Rumig" <derek.rumig@rogers.com> wrote in message news:2tJoc.3301$oq3.18315@newscontent-01.sprint.ca... > Does anyone know if you should be able to see appointments in your calendar > before accepting them....

Question about ISAPI Server Extension
hi, I'm trying to develop something with ISAPI. But so far , I'm not clearly understand on 2 point: 1.How to debug isapi project ? there seems not a effical way to deal with it. 2.I decleared some variants in CTestExtension.How to know whether it's golobal or local? I've tried to declear a member variant like this: private: CString m_Keywords; I find that the value of it is what it is when the last visitor visits . any one can give me some suggestion? many thanks. :) Hi, To debug, go into services in the control panel and shutdown IIS. In VC with your project loaded...

A little question
Using secured version of 'strcpy()' I need to use 'strcpy_s()' version and there lies my problem. In my function I need to copy the result in a char type which is passed to function. I pass a 'char addr[256]' but on my final step function: 'strcpy_s(addr, sizeof(addr), result)' the sizeof operator returns '4' and function chrases. The value of result is lets say an IP address (11 characters). What can I use instead 'sizeof' operater. I cant just use 256 because I use 'myfunction' in few places and passing different kind of char ar...

x-y Line Graph question
I have a line graph. X is dates and Y is numeric data. I am plotting 12/1/2005 through 1/30/2006. The problems is my series does not start at the "left most" point of 12/1/2005, it is shifted slightly. And the line does not end at the "right most" point of 1/30/2006. Any ideas will be appreciated. thanks! XL has two distinct chart types even though they look similar, the XY Scatter chart and the Line chart. There is no XY Line graph. I believe you have a Line graph. Double-click the x-axis and from the Scale tab uncheck the 'Value (Y) axis crosses betwe...

Icon questions
Hello group, I want to assign an icon to my application using Visual C++ 6.0. Here are the problems I'm having: 1. The Visual C++ Graphics editor limits the choice of the colors. If I use a color from the Custom Color Selector dialog box that doesn't exist in the palette, when I build the app the color changes to the nearest one in the palette. 2. Even though I use the available colors to create a 32x32-256-color icon, when I execute my app the icon displayed in the upper left corner of my app's window, in the taskbar, and in Windows Explorer (in the details and list vi...

FE/BE question
Hi, When an environment has a single FE and BE, during the initial setup, do the permissions change on Exchsrvr folder of either Exch server, or do they simply retain the default permissions (as seen in KB 322935)? thanks, Mel On Thu, 12 Oct 2006 04:54:02 -0700, Mel <Mel@discussions.microsoft.com> wrote: >Hi, > >When an environment has a single FE and BE, during the initial setup, do the >permissions change on Exchsrvr folder of either Exch server, or do they >simply retain the default permissions (as seen in KB 322935)? > >thanks, > >Mel The perms st...

Reformat Data Question
How can I get data that looks like this: A B C D E 1 YEAR JAN FEB MAR .... 2 1947 21.5 21.5 21.9 .... 3 1948 23.7 23.5 23.4 .... 4 1949 21.5 21.5 21.9 .... 5 ........ ....... ....... ....... .... Into a format like this: A B 1 1/1/1947 21.5 2 2/1/1947 21.5 3 3/1/1947 21.9 ... .............. ...... 13 1/1/1948 23.7 13 2/1/1948 23.5 -- sslack -------------------------------------------------...

Help
I am a newbie to RMS I am trying to get my scanner to read a pre-weighed bar-code created from a stand-alone digi scale. The format is as follows: 0 203327 700695 (03327 = plu & 069 = price 69 cents) My scanners will read other barcodes in different formats (soda, dogfood etc.) and populates the item into the current transaction. The scanner also reads the above code (without the zero) 203327700795 but doesn't populayte the item into the transaction. Any and all help is greatly appreciated as we are slated to open tomorrow! Did you follow these exact steps? Rob Issue How...

My Tasks Questions
Hi guys, I had a few questions in relation to the My Tasks view in Project Server 2007. Is it possible to change the default time period? Right now it is currently going to the next week when you go into the My Tasks web part. For example, it opens to the week of Dec. 28th right now. My other question is if there is a way to show the total hours entered like the timesheets do. So if a resource enters their time for the week they don't have to add the days together across their assignments to make sure they entered 40 hours. Thanks for your help! The Actual work column...

Newible question
Dear All, I am a fresh graduated student, Now I am a system engineer to maintain our company exchange server 2000 and 2003. How to see the server is running without problem or where i should put more effort. Now, I see event log per day, but i think not very efficient and effective. And I also use system manager to see how much mail queue to determine the server is running smoothly or not. Best wishes & Thank all down load and install Exchange best practices and analyses tool for a start. It analyses your system and give feedback - google for it craig "Chi" <csyckad@g...

2003 Money (Can I -) question
Is it possible to change or preset defaults for the drop down fields used to create new recurring bill under [Bills & Deposits]? For example; [Write Check] is the default in the payment method. I want it to be [Print Check]. [Monthly] is default for the frequency and I want [Only Once]. I would like to be able to set my most used selections as defaults. Thanks - Andy Nope. "Andy" <a1cotton@knology.net> wrote in message news:079b01c392c3$6cfe0290$a301280a@phx.gbl... > Is it possible to change or preset defaults for the drop > down fields used to create new...

Custom Form Question #2
I have created two almost identical custom forms for Outlook 2007 in an exchange environment. The forms are based on the task form, and simply have a second tab that we each sign off on the steps of our projects as they go. We create those forms by going to action|new "custom" form. However, one of the forms appears as a task with a task icon in the task folder when I create it. But, the other shows up in the task folder, but with a post item icon, that is the little yellow sticky note with the blue push pin in it. I can't find where you set this attribute and why one form i...

xmlNode.InnerText vs. xmlNode.Value
I've loaded the following xml into an XMLDocument object: <?xml version="1.0" ?> - <Preferences> <Institution>Argh</Institution> <Speaker>Chigier, Ben (1234)</Speaker> <Worktype>Addendum</Worktype> <speakerCode>1234</speakerCode> </Preferences> I then try to retrieve the value of the Institution node as follows: string s = myxmldoc.SelectSingleNode("/Preferences/Institution").Value; However, s is null after the call. But if I change the call to the following, s is what I'd expect: "A...

Flexgrid question
Hi All, Is it possible to apply certain styles to a part of the cell and not to the entire cell. For example I want to change background color of a particular character (not the whole cell) in a cell. Is it possible or I'm just wasting my time on flexgrid. By the way I'm using MS Hierarchical flex grid control. Thanks Irfan ...

Color-filled cell questions
I've copied Chip Pearson's VBA code for 'counting cells with a specific color' into my spreadsheet - and it works - but: 1) If I protect the sheet, even though I leave the cells to be colored (fill color tool) unprotected, I cannot fill/color the cells. They act like they are protected, too. If I select Tools to format the cells, the cell selection is grayed out. 2) How do I get the results of the formula to show after the cell is colored? It eventually shows, but I would like it to show after tabbing from the cell. (Please note the first sentence - I know how to co...

licensing questions
I recently purchased a copy of both Office:mac 2004 and Virtual PC 7 for mac from an online auction.they can with all documentation, COA and licensing keys. can i legally install this software? i do not know if the original owner has removed this application, and have no way to verify.heck, i'm not sure it was ever installed. if this is ok to install, is there anything i can do to Re-register product keys with MS so that i can be shown as the legitimate owner with MS ? In article <1173807845.048001.8240@s48g2000cws.googlegroups.com>, condemnd4life@yahoo.com wrote: > I recently...

Questions about Windows Desktop Manager
Im looking into using the windows desktop manager to capture the image displayed on a certain &#119;indow.Currently Im brining the window in question to the top of the screen before taking a standard screenshot- This is inconvenient since I want a shot taken every minute, and i dont really need/want the window at the top all the time anyway.Im only used to programming in Matlab so I have some questions which may seem stupid, nonetheless answers to these would help me a lot:1. Is there a fee to get hold of the Windows Desktop Manager API for Vista?2. What language is the API written in?3. I...

How to get the XML path of an XmlNode?
How can I get the full XML path (as string) of a specific XmlNode ? -- Thanks Sharon Sharon wrote: > How can I get the full XML path (as string) of a specific XmlNode ? What is "the full XML Path" of a node, do you have any definition for that? Some XML editors can assist you constructing or maybe even generating an XPath expression. -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ Lets say I have the following XML file: <?xml version="1.0" encoding="utf.8"?> <System Name = "System"> <Parameters> <T1&...

Excel question, help plz
I need to make a spreadsheet for a cinema How can i make it so that each time a seat is sold the cell tha corresponds to that seat changes color? Thank -- Message posted from http://www.ExcelForum.com Knad wrote: > *I need to make a spreadsheet for a cinema > > How can i make it so that each time a seat is sold the cell tha > corresponds to that seat changes color? > > Thanks * Hi, You can use Conditional Formatting for this. What will your column headings be? And, the cell in which corresondin column would you like to change color? Or would you like the whole ro...

Basic questions
Hello all, 1. Does Access 97 run on Vista? 2. Please send a Link with information if it does. JC Papi rules Although I haven't installed it yet, I plan to because it should run without anything but the same installation issues that Access 97 always had. There is no link since Office 97 has been unsupported for about 5 years. If you do install, make absolutely sure that you install both service packs. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "Joe C" <JoeC@discussions.microsoft.com> wrote in message news:53...

POP3 Question #4
Hi, I have SBS 2003 wiuth Exchange 2003 where I am downloading my email into a global mailbox. Is there a way i can view a log or status to see if mail is being downloaded? Thanks ...

Question on the stringtable
Hello, Is there any way to programmatically change the value in the stringtable entry in the resources? Thank You! > Is there any way to programmatically change the value in the stringtable >entry in the resources? I don't know the details, but have a look for examples of code that make use of the BeginUpdateResource, UpdateResource, and EndUpdateResource APIs. Dave -- MVP VC++ FAQ: http://www.mvps.org/vcfaq ...