473,396 Members | 2,011 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,396 software developers and data experts.

XML XPath question. Simple XML File

Ok,

Here is my XML File, it's pretty simple:
<?xml version="1.0" encoding="utf-8" ?>
<Dispositions>
<Group Name="Unused">
<Disp>NA</Disp>
<Disp>TCB</Disp>
<Disp>WPC</Disp>
</Group>
<Group Name="Refusals">
<Disp>PM</Disp>
<Disp>REF</Disp>
<Disp>SVN</Disp>
<Disp>SFV</Disp>
<Disp>KO</Disp>
<Disp>UNV</Disp>
<Disp>VTCB</Disp>
</Group>
<Group Name="Voids">
<Disp>AO</Disp>
<Disp>DISC</Disp>
<Disp>INEL</Disp>
<Disp>LB</Disp>
<Disp>MC</Disp>
<Disp>WRN</Disp>
</Group>
<Group Name="Sales">
<Disp>RS</Disp>
<Disp>SALE</Disp>
<Disp>SI</Disp>
<Disp>SIE</Disp>
<Disp>VS</Disp>
<Disp>WCS</Disp>
</Group>
<Group Name="DNC">
<Disp>DNC</Disp>
</Group>
</Dispositions>
Here is the code I am using:

Dim doc As System.Xml.XmlDocument
doc = New XmlDocument
doc.Load("Dispositions.xml")
Dim Root As XmlElement = doc.DocumentElement
Dim node As XmlNodeList
node = Root.SelectNodes("/Dispositions/Group/@Name")
Dim i As Integer
Dim j As Integer
For i = 0 To node.Count - 1 Step i + 1
Debug.WriteLine("-" & node.Item(i).Value)
Dim sNodes As XmlNodeList =
node(i).SelectNodes("/Dispositions/Group[Name=" & node.Item(i).Value &
"]/Disp/text()")
For j = 0 To sNodes.Count - 1 Step j + 1
Debug.WriteLine("--" & sNodes.Item(j).Value)
Next
Next
Right now it only lists this:

-Unused
-Refusals
-Voids
-Sales
-DNC

What I want to do is, depending on the user, they will click a button
that will grab all <Disp> underneath a specific <Group
name="whatever"></Group>

These are actually codes to be used in a sql query that will grab
certain records.

This is my first time working with XML in dotnet and I am quite
confused. Where can i go to get a basic understanding of the Nodes,
Nodelists, etc....

Can anyone tell me how to accomplish what it is i'm trying to do here.
thank you.
Nov 12 '05 #1
2 1608
Ice
Where can you go?

Framework SDK.

maybe this will work..

assuming vName is the selection

/Group[@Name=vname]

ice

"DKode" <dk***@cfl.rr.com> wrote in message
news:b1**************************@posting.google.c om...
Ok,

Here is my XML File, it's pretty simple:
<?xml version="1.0" encoding="utf-8" ?>
<Dispositions>
<Group Name="Unused">
<Disp>NA</Disp>
<Disp>TCB</Disp>
<Disp>WPC</Disp>
</Group>
<Group Name="Refusals">
<Disp>PM</Disp>
<Disp>REF</Disp>
<Disp>SVN</Disp>
<Disp>SFV</Disp>
<Disp>KO</Disp>
<Disp>UNV</Disp>
<Disp>VTCB</Disp>
</Group>
<Group Name="Voids">
<Disp>AO</Disp>
<Disp>DISC</Disp>
<Disp>INEL</Disp>
<Disp>LB</Disp>
<Disp>MC</Disp>
<Disp>WRN</Disp>
</Group>
<Group Name="Sales">
<Disp>RS</Disp>
<Disp>SALE</Disp>
<Disp>SI</Disp>
<Disp>SIE</Disp>
<Disp>VS</Disp>
<Disp>WCS</Disp>
</Group>
<Group Name="DNC">
<Disp>DNC</Disp>
</Group>
</Dispositions>
Here is the code I am using:

Dim doc As System.Xml.XmlDocument
doc = New XmlDocument
doc.Load("Dispositions.xml")
Dim Root As XmlElement = doc.DocumentElement
Dim node As XmlNodeList
node = Root.SelectNodes("/Dispositions/Group/@Name")
Dim i As Integer
Dim j As Integer
For i = 0 To node.Count - 1 Step i + 1
Debug.WriteLine("-" & node.Item(i).Value)
Dim sNodes As XmlNodeList =
node(i).SelectNodes("/Dispositions/Group[Name=" & node.Item(i).Value &
"]/Disp/text()")
For j = 0 To sNodes.Count - 1 Step j + 1
Debug.WriteLine("--" & sNodes.Item(j).Value)
Next
Next
Right now it only lists this:

-Unused
-Refusals
-Voids
-Sales
-DNC

What I want to do is, depending on the user, they will click a button
that will grab all <Disp> underneath a specific <Group
name="whatever"></Group>

These are actually codes to be used in a sql query that will grab
certain records.

This is my first time working with XML in dotnet and I am quite
confused. Where can i go to get a basic understanding of the Nodes,
Nodelists, etc....

Can anyone tell me how to accomplish what it is i'm trying to do here.
thank you.

Nov 12 '05 #2
You have one small typo in your 2nd "SelectNodes"
statement.

The "Name" attribute is referenced by "@Name", not
just "Name". If you stick a "@" in front of "Name" in the
snippet below your code will work

node(i).SelectNodes("/Dispositions/Group[Name=" & node.Item
(i).Value &
"]/Disp/text()")

-----Original Message-----
Ok,

Here is my XML File, it's pretty simple:
<?xml version="1.0" encoding="utf-8" ?>
<Dispositions>
<Group Name="Unused">
<Disp>NA</Disp>
<Disp>TCB</Disp>
<Disp>WPC</Disp>
</Group>
<Group Name="Refusals">
<Disp>PM</Disp>
<Disp>REF</Disp>
<Disp>SVN</Disp>
<Disp>SFV</Disp>
<Disp>KO</Disp>
<Disp>UNV</Disp>
<Disp>VTCB</Disp>
</Group>
<Group Name="Voids">
<Disp>AO</Disp>
<Disp>DISC</Disp>
<Disp>INEL</Disp>
<Disp>LB</Disp>
<Disp>MC</Disp>
<Disp>WRN</Disp>
</Group>
<Group Name="Sales">
<Disp>RS</Disp>
<Disp>SALE</Disp>
<Disp>SI</Disp>
<Disp>SIE</Disp>
<Disp>VS</Disp>
<Disp>WCS</Disp>
</Group>
<Group Name="DNC">
<Disp>DNC</Disp>
</Group>
</Dispositions>
Here is the code I am using:

Dim doc As System.Xml.XmlDocument
doc = New XmlDocument
doc.Load("Dispositions.xml")
Dim Root As XmlElement = doc.DocumentElement
Dim node As XmlNodeList
node = Root.SelectNodes ("/Dispositions/Group/@Name") Dim i As Integer
Dim j As Integer
For i = 0 To node.Count - 1 Step i + 1
Debug.WriteLine("-" & node.Item(i).Value)
Dim sNodes As XmlNodeList =
node(i).SelectNodes("/Dispositions/Group[Name=" & node.Item(i).Value &"]/Disp/text()")
For j = 0 To sNodes.Count - 1 Step j + 1
Debug.WriteLine("--" & sNodes.Item (j).Value) Next
Next
Right now it only lists this:

-Unused
-Refusals
-Voids
-Sales
-DNC

What I want to do is, depending on the user, they will click a buttonthat will grab all <Disp> underneath a specific <Group
name="whatever"></Group>

These are actually codes to be used in a sql query that will grabcertain records.

This is my first time working with XML in dotnet and I am quiteconfused. Where can i go to get a basic understanding of the Nodes,Nodelists, etc....

Can anyone tell me how to accomplish what it is i'm trying to do here.thank you.
.

Nov 12 '05 #3

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

Similar topics

0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
0
by: mig | last post by:
I have XML Schema (or DTD) file and XPath String on the input and need piece of Java code (probably using some free API) which will give me the answer to the following question: "Can we build an...
7
by: Sebastian Petzelberger | last post by:
Hi group, please give me an example of a xpath with regex or better a link with examples. Thanks in advance, Sebastian
7
by: Ot | last post by:
I posted this to the wrong group. It went to m.p.dotnet.languages.vb. Ooops. -------------------------------------------------------------------- I have this tiny problem. I have learned...
3
by: bruce | last post by:
for guys with python/xpath expertise.. i'm playing with xpath.. and i'm trying to solve an issue... i have the following kind of situation where i'm trying to get certain data. i have a...
3
by: werD | last post by:
Hello I have an xml document that im currently using a forward only .net repeater on and using some xpath queries to display the data The xml is quite simple <?xml version="1.0"...
7
by: Tim Hallwyl | last post by:
Hi, there! As I understand the XPaht recommendation, the context node is a node; not a node-list, not XPath object -- but a single node. Now, the WS-BPEL 2.0 specification allows an XML simple...
5
by: rcronk | last post by:
I'm new to C#/.NET. I am writing some C#/.NET (2.0) classes that will allow someone to get and set values in an XML file using an XPath to point to the location of that data. It's more complicated...
0
by: Curtin1060 | last post by:
Hi, I have a simple exe.config issue where I'd like to swap out the config file with NAnt/XMLPOKE. I just can't figure out the correct xpath to get to the "file=" attribute. I want to swap in...
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: 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
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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,...

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.