473,378 Members | 1,391 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,378 software developers and data experts.

Selecting XML nodes

Does anyone know the notation of how to select XML nodes based on an
attribute. I know that it will be something like:
root.SelectNodes ("descendant::key....")

Sample xml is
<indexdata>
<key name="buffy">
<topic name="buffy" url="buffy/buffy.htm"/>
<topic name="scooby gang" url="buffy/good_guys/scooby_gang.htm" />
</key>
</indexdata>

Basically, I want to get the url when the name = buffy or scooby gang.
I know, I have such an interesting help file. ;)

Thank you,
Susan
Nov 16 '05 #1
2 2597
This line:
foreach(XmlNode db in x.SelectNodes("/jobs/job[@sourcedb and @destdb and
@name]"))

selects all the "job" nodes represented in this XML file:
(ONLY if they have got a valid sourcedb and destdb attribute):

<?xml version="1.0" encoding="utf-8" ?>
<jobs>
<job name="System info" sourcedb="irf0429" destdb="SystemInfo.mdb">
<table name="SystemInfo"/>
</job>
<job name="Collections vs. Maturities" sourcedb="irf0429"
destdb="CollsMaturities.mdb">
<table name="EXC_AgencyCollsMature"/>
<table name="EXC_BranchCollsMature"/>
<table name="EXC_SectionCollsMature"/>
<table name="EXC_ROMCollsMature"/>
<table name="EXC_DOMCollsMature"/>
<table name="EXC_CompanyCollsMature"/>
<table name="GRAPH_AgencyCollsMature"/>
<table name="GRAPH_BranchCollsMature"/>
<table name="GRAPH_SectionCollsMature"/>
<table name="GRAPH_ROMCollsMature"/>
<table name="GRAPH_DOMCollsMature"/>
<table name="GRAPH_CompanyCollsMature"/>
</job>
</jobs>

don't know if that's any help to you, hope so
"Susan" wrote:
Does anyone know the notation of how to select XML nodes based on an
attribute. I know that it will be something like:
root.SelectNodes ("descendant::key....")

Sample xml is
<indexdata>
<key name="buffy">
<topic name="buffy" url="buffy/buffy.htm"/>
<topic name="scooby gang" url="buffy/good_guys/scooby_gang.htm" />
</key>
</indexdata>

Basically, I want to get the url when the name = buffy or scooby gang.
I know, I have such an interesting help file. ;)

Thank you,
Susan

Nov 16 '05 #2
I was able to get the answer from that. I just needed the @name and was able
to put in the ='Cats'. Thank you so much!!!

"Patty O'Dors" wrote:
This line:
foreach(XmlNode db in x.SelectNodes("/jobs/job[@sourcedb and @destdb and
@name]"))

selects all the "job" nodes represented in this XML file:
(ONLY if they have got a valid sourcedb and destdb attribute):

<?xml version="1.0" encoding="utf-8" ?>
<jobs>
<job name="System info" sourcedb="irf0429" destdb="SystemInfo.mdb">
<table name="SystemInfo"/>
</job>
<job name="Collections vs. Maturities" sourcedb="irf0429"
destdb="CollsMaturities.mdb">
<table name="EXC_AgencyCollsMature"/>
<table name="EXC_BranchCollsMature"/>
<table name="EXC_SectionCollsMature"/>
<table name="EXC_ROMCollsMature"/>
<table name="EXC_DOMCollsMature"/>
<table name="EXC_CompanyCollsMature"/>
<table name="GRAPH_AgencyCollsMature"/>
<table name="GRAPH_BranchCollsMature"/>
<table name="GRAPH_SectionCollsMature"/>
<table name="GRAPH_ROMCollsMature"/>
<table name="GRAPH_DOMCollsMature"/>
<table name="GRAPH_CompanyCollsMature"/>
</job>
</jobs>

don't know if that's any help to you, hope so
"Susan" wrote:
Does anyone know the notation of how to select XML nodes based on an
attribute. I know that it will be something like:
root.SelectNodes ("descendant::key....")

Sample xml is
<indexdata>
<key name="buffy">
<topic name="buffy" url="buffy/buffy.htm"/>
<topic name="scooby gang" url="buffy/good_guys/scooby_gang.htm" />
</key>
</indexdata>

Basically, I want to get the url when the name = buffy or scooby gang.
I know, I have such an interesting help file. ;)

Thank you,
Susan

Nov 16 '05 #3

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

Similar topics

2
by: kj | last post by:
Suppose I have some XML document that contains tags of the form <... xmlns:foo="http://www.bar.org/foo"> <... xmlns:foo="baz"> <... xmlns:frobozz="http://www.bar.org/foo"> What's the...
2
by: Mike Kamermans | last post by:
I'm having some trouble using text() in an xsl:value-of xpath. I have the following xml: .... <graphemes> <grapheme>1</grapheme> <grapheme>2</grapheme> <grapheme>3</grapheme> </graphemes>...
2
by: Dag | last post by:
Hi I am pretty much an xml beginner; hopefully someone can easily answer this one... I want to select a node representing a worksheet in an xml document for the Office Web Components spreadsheet....
2
by: Saurabh Sharma | last post by:
Hi, I am using Dom Parsing in Xml. I am the parent node and it has many children and each children has many children. I want to select children with a given name . Is there any method by which we...
4
by: JoKur | last post by:
I'm currently using a context menu to allow the user to add, rename and delete nodes in a treeview control. When a node is added we give it a bogus name ("NewNode") and invoke the add method. We...
1
by: Stefan | last post by:
Hey guys ! Can someone pls help me and tell me how it is possible to Select a Node in 2nd row? I got a treeview which is build like follows: node2.Nodes.Add("blah", "blubb");...
2
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
7
by: PatrickRThomas | last post by:
I need help selecting nodes while excluding some of them. Here's an example of XML: <my_xml> <all_items> <item> <key>1</key> <name>Item 1</name> </item> <item>
2
by: dav61000 | last post by:
I am new to VB.net so I am not sure if there is a good way to do this or not but here is my problem. I have created a form with a TreeView control on it. When the user selects a node from the...
1
by: DeveloperX | last post by:
Hi, I should probably start with my XML as it makes it easier to explain the problem. <?xml version="1.0" encoding="utf-8" ?> <aa note="top level"> <b1 note="b1"> <c1 note="b1 c1"> <d1...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: 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?
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...

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.