473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

looking for example of inserting child node using a for each on a nodelist

Hi,

I'm looking for an example (preferably vb) using xmlDocument class
that once an XmlNodeList has been set (e.g., select all <House>
elements), that would add an empty <Rooms> child element to each
<House>.

Thanks in advance for any help.

Kathy
Nov 11 '05 #1
1 1378
Imports System
Imports System.Xml
Public Class Sample
Public Shared Sub Main()

Dim doc As New XmlDocument()
doc.LoadXml("<root><house id='1'/><house id='2' /></root>")

Console.WriteLine(doc.OuterXml) 'BEFORE
Dim node As XmlNode
For Each node In doc.SelectNodes("/root/house")
node.AppendChild(doc.CreateElement("rooms"))
Next node

Console.WriteLine(doc.OuterXml) 'AFTER
End Sub 'Main
End Class 'Sample
--
This posting is provided "AS IS" with no warranties, and confers no rights.

"KathyB" <Ka**********@attbi.com> wrote in message
news:75**************************@posting.google.c om...
Hi,

I'm looking for an example (preferably vb) using xmlDocument class
that once an XmlNodeList has been set (e.g., select all <House>
elements), that would add an empty <Rooms> child element to each
<House>.

Thanks in advance for any help.

Kathy

Nov 11 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: indo3 | last post by:
Hello, I program an xml editor with xerces for the university of Braunschweig, the user dont see any xml tags, it is represented in a JTree. Now the user shall be able to insert nodes, which...
2
by: Lutz Ißler | last post by:
Hi all! I dymically replace the child nodes of a DIV element by image nodes. In IE and Firefox this works properly. In Safari it works properly, too - but only if the site is called locally, eg....
3
by: chris yoker via DotNetMonster.com | last post by:
hi, I have an xmlFile <code> <rows> <row> <PRODUCT-TYPE>bike</PRODUCT-TYPE> <PRODUCT-DATE>01/01/2004</PRODUCT-DATE> <ADDED-NODE>"blah"<ADDED-NODE /> </row>
2
by: William | last post by:
Have somebody a brilliant idea how to remove a nodelist in a XML document? (With C#) I have this xml file,I want delete the stock nodelist when an user don't have permissions to see stocklist of...
6
by: vbmark | last post by:
I have the follwing XML string: <RecordSet> <Row RowNumber="1"> <UserID>111</UserID> <Phone>1234567890</Phone> </Row> <Row RowNumber="2"> <UserID>747</UserID> <Phone>9876543210</Phone>
2
by: Christian Rühl | last post by:
heyho, guys! here's another question for you now: i built an iterator to get all the nodes with a certain attribute in an xml dom. it all looks like this (i'm using .NET framework 1.1) ...
11
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so many parameters need to be passed into store...
14
by: marfi95 | last post by:
I'm trying to iterate through a list of child nodes. It seems like to get the text value of the node, you have to do a node->getFirstChild()->getNodeValue. This being said, there is a...
0
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.