473,511 Members | 15,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XMLnodes and childs

I have a xml file like:

<root>
<item>
<car type="4wd">
<manufactored>1-1-1999</manufactored>
<color>red</color>
<length>2.40m</length>
</car
</item>
<item>
<car type="bus">
<manufactored>1-1-1999</manufactored>
<color>red</color>
<length>2.40m</length>
</car
</item>
</root>

If a car type is bus then I want to change it's length. I have the following
code:

Dim xmld As XmlDocument
Dim nodelist As XmlNodeList
Dim node As XmlNode
xmld = New XmlDocument
xmld.Load(CmdArgs(1))
nodelist = xmld.SelectNodes("/root/item/car")
For Each node In nodelist
If node.Attributes.GetNamedItem("type").Value =
"bus" Then
'change length
End If
Next

The code checks what type the car is. Now I can want to access <length>. I
only found an example that uses node.ChildNodes.Item(0).InnerText etc.. but
that depends on childnodes to be in a particulair sequence. How can I change
the value of length if I do not know which childnodeitem contains <length>?
Do I need to create for each loop to check this?
Nov 21 '05 #1
2 963
node.item("length").innertext
Philip Wagenaar wrote:
I have a xml file like:

<root>
<item>
<car type="4wd">
<manufactored>1-1-1999</manufactored>
<color>red</color>
<length>2.40m</length>
</car
</item>
<item>
<car type="bus">
<manufactored>1-1-1999</manufactored>
<color>red</color>
<length>2.40m</length>
</car
</item>
</root>

If a car type is bus then I want to change it's length. I have the following
code:

Dim xmld As XmlDocument
Dim nodelist As XmlNodeList
Dim node As XmlNode
xmld = New XmlDocument
xmld.Load(CmdArgs(1))
nodelist = xmld.SelectNodes("/root/item/car")
For Each node In nodelist
If node.Attributes.GetNamedItem("type").Value =
"bus" Then
'change length
End If
Next

The code checks what type the car is. Now I can want to access <length>. I
only found an example that uses node.ChildNodes.Item(0).InnerText etc.. but
that depends on childnodes to be in a particulair sequence. How can I change
the value of length if I do not know which childnodeitem contains <length>?
Do I need to create for each loop to check this?

Nov 21 '05 #2
Hi Philip,

How is the thing going?
Did Matt's suggestion help you?
If you still have any concern, please feel free to post here.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #3

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

Similar topics

1
1221
by: Markus Franz | last post by:
Hi! Inside a Python script (I use Python 2.4) several different child processes are created by using os.fork(). My problem: I want only the parent process to print some output and then...
3
570
by: -H | last post by:
Hi, I have a "parent" C program that forks off a "child" C program. Both the parent and the child print information to both stdout and stderr. I would like to redirect the parent and childs...
2
1855
by: Sergio del Amo Caballero | last post by:
Hi, I have a structer like this: <div class="node"> <a><img /></a> <div class="child"> <a><img /></a> </div> <div class="child"> <a><img /></a>
8
2498
by: Todd Bright | last post by:
Is there a way to get the current XmlNode from the reader while in the validation event handler? What I'd like to do is display the error message along with the name of its parent node. In my...
2
2139
by: Bob Hollness | last post by:
Hi group. Merry Xmas one and all!!!! I hope Santa brings you all something good. For me, I would be happy with some nice code! If I check a node in a treeview, how do I check all childs of...
1
1263
by: Stampede | last post by:
Hello, I created a Windows Application Project and tried to create a MDI-based application. So I created a new MDI-parent with the creation wizzard. Then I created a default form and tried to make...
2
987
by: Jan Kucera | last post by:
Hi, I have two elements in XmlNode objects belonging to one XmlDocument. How can I get the xml markup between these two? I mean if the document looks like <parent> <child1 /> <child2 />...
6
2633
by: ahmed.maryam | last post by:
Hi Everyone, How can I check for end elements in a XmlNodeList that consists of all the children nodes in my XML document? Can I avoid using XmlReader or XPath Navigator? Thanks for any help! ...
0
7252
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,...
0
7153
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...
0
7371
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,...
0
7432
jinu1996
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...
0
7517
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...
0
5676
agi2029
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,...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
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...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.