473,799 Members | 3,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please ... example code due on looping though specific nodes

I am quite new to XML and posted a request for example code yesterday.
Unfortunately, I did not do a very good job in explaining what I was
looking for. Here is an example of a small piece of the file:

<Scoreboard>
<Events>
<Event ID="001212" Name="EventName 1" />
<Event ID="001213" Name="EventName 2" />
<Event ID="001214" Name="EventName 3" />
<Event ID="001215" Name="EventName 4" />
</Events>
<EventTypes>
<EventType ID="01" SingleGame="tru e" Name="EventName 1" />
<EventType ID="02" SingleGame="tru e" Name="EventName 2" />
<EventType ID="03" SingleGame="tru e" Name="EventName 3" />
<EventType ID="04" SingleGame="tru e" Name="EventName 4" />
<EventType ID="05" SingleGame="tru e" Name="EventName 5" />
<EventType ID="06" SingleGame="tru e" Name="EventName 6" />
<EventType ID="07" SingleGame="tru e" Name="EventName 7" />
</EventTypes>
<Teams>
<Team ID="11" City="City1" Name="Name1" City="City1"
Nickname="nickn ame1" Conference="Con ference1">
<Player ID="91" />
<Player ID="190" />
<Player ID="77" />
<Player ID="133" />
<Player ID="144" />
<Player ID="195" />
<Player ID="220" />
<Player ID="231" />
<Player ID="214" />
<Team ID="13" City="City2" Name="Name2" City="City2"
Nickname="nickn ame2" Conference="Con ference1">
<Player ID="91" />
<Player ID="190" />
<Player ID="77" />
<Player ID="133" />
<Player ID="144" />
<Player ID="195" />
<Player ID="220" />
<Player ID="231" />
<Player ID="214" />
</Team>
</Teams>
<Match ID="999" StatusType="6" IsChallengeEnab led="false"
VenueID="NBB" SchedDate="2006-07-30" SchedTime="13:0 0"
ElapsedTime="02 :01" Winner="H" Attendance="" Final="Y">
<ChairUmpires >
<ChairUmpire Num="1" Name="" />
<ChairUmpire Num="2" Name="" />
</ChairUmpires>
<Teams>
<Team ID="1" Type="H" ChallengesMade= "5" ChallengesWon=" 3">
<Player ID="162" Coach="N" />
<Player ID="92" Coach="N" />
<Player ID="127" Coach="N" />
<Player ID="183" Coach="N" />
<Player ID="58" Coach="Y" />
<Stats FSPts="77" FSPtsWon="53" SSPts="21" SSPtsWon="11"
FSAces="2" SSAces="2" DF="2" TeamBrkPts="16" TeamBrkPtsWon=" 6"
TotPtsWon="110" TeamDeucePts="6 " TeamDeucePtsWon ="1" GamesPlayed="35 "
GamesWon="21" />
</Team>
</Match>
</Scoreboard>

How could I loop through a specific node, such as "Scoreboard/Teams"
and pull out all the information for ONLY that specific node? Once
that is done I would like to be able to move to another node such as
"Match/Teams" and loop through only that node and get all the info. I
would not need to loop through every node in the file, just specific
ones.

As I mentioned, this is just a small sample of the file, it is more
complex than this, but if I could get to this stage I could figure the
rest out. All this info must be put into a database.

Please if anyone has an example on how to do this, I would really
appreciate it. I am in urgent need of getting this done immediately.

Thanks,
Steve

Jun 3 '07 #1
67 2688
On Jun 3, 5:58 pm, gator <glb...@gmail.c omwrote:
I am quite new to XML and posted a request for example code yesterday.
Unfortunately, I did not do a very good job in explaining what I was
looking for. Here is an example of a small piece of the file:

<Scoreboard>
<Events>
<Event ID="001212" Name="EventName 1" />
<Event ID="001213" Name="EventName 2" />
<Event ID="001214" Name="EventName 3" />
<Event ID="001215" Name="EventName 4" />
</Events>
<EventTypes>
<EventType ID="01" SingleGame="tru e" Name="EventName 1" />
<EventType ID="02" SingleGame="tru e" Name="EventName 2" />
<EventType ID="03" SingleGame="tru e" Name="EventName 3" />
<EventType ID="04" SingleGame="tru e" Name="EventName 4" />
<EventType ID="05" SingleGame="tru e" Name="EventName 5" />
<EventType ID="06" SingleGame="tru e" Name="EventName 6" />
<EventType ID="07" SingleGame="tru e" Name="EventName 7" />
</EventTypes>
<Teams>
<Team ID="11" City="City1" Name="Name1" City="City1"
Nickname="nickn ame1" Conference="Con ference1">
<Player ID="91" />
<Player ID="190" />
<Player ID="77" />
<Player ID="133" />
<Player ID="144" />
<Player ID="195" />
<Player ID="220" />
<Player ID="231" />
<Player ID="214" />
<Team ID="13" City="City2" Name="Name2" City="City2"
Nickname="nickn ame2" Conference="Con ference1">
<Player ID="91" />
<Player ID="190" />
<Player ID="77" />
<Player ID="133" />
<Player ID="144" />
<Player ID="195" />
<Player ID="220" />
<Player ID="231" />
<Player ID="214" />
</Team>
</Teams>
<Match ID="999" StatusType="6" IsChallengeEnab led="false"
VenueID="NBB" SchedDate="2006-07-30" SchedTime="13:0 0"
ElapsedTime="02 :01" Winner="H" Attendance="" Final="Y">
<ChairUmpires >
<ChairUmpire Num="1" Name="" />
<ChairUmpire Num="2" Name="" />
</ChairUmpires>
<Teams>
<Team ID="1" Type="H" ChallengesMade= "5" ChallengesWon=" 3">
<Player ID="162" Coach="N" />
<Player ID="92" Coach="N" />
<Player ID="127" Coach="N" />
<Player ID="183" Coach="N" />
<Player ID="58" Coach="Y" />
<Stats FSPts="77" FSPtsWon="53" SSPts="21" SSPtsWon="11"
FSAces="2" SSAces="2" DF="2" TeamBrkPts="16" TeamBrkPtsWon=" 6"
TotPtsWon="110" TeamDeucePts="6 " TeamDeucePtsWon ="1" GamesPlayed="35 "
GamesWon="21" />
</Team>
</Match>
</Scoreboard>

How could I loop through a specific node, such as "Scoreboard/Teams"
and pull out all the information for ONLY that specific node? Once
that is done I would like to be able to move to another node such as
"Match/Teams" and loop through only that node and get all the info. I
would not need to loop through every node in the file, just specific
ones.

As I mentioned, this is just a small sample of the file, it is more
complex than this, but if I could get to this stage I could figure the
rest out. All this info must be put into a database.

Please if anyone has an example on how to do this, I would really
appreciate it. I am in urgent need of getting this done immediately.

Thanks,
Steve
Hi Steve,

Try using XPathNavigator class.
http://msdn2.microsoft.com/en-us/lib...navigator.aspx

Hope this helps.
Moty

Jun 3 '07 #2

On Sun, 03 Jun 2007 07:58:06 -0700, gator <gl****@gmail.c omwrote:
I am quite new to XML and posted a request for example code yesterday.
Unfortunately, I did not do a very good job in explaining what I was
looking for. Here is an example of a small piece of the file:
.. [...]
>
How could I loop through a specific node, such as "Scoreboard/Teams"
and pull out all the information for ONLY that specific node? Once
that is done I would like to be able to move to another node such as
"Match/Teams" and loop through only that node and get all the info. I
would not need to loop through every node in the file, just specific
ones.
There is no need to start a new thread, or even to repost the sample
data. If you feel that you should elaborate or clarify the original post,
you can and should simply reply in that original thread, so that all of
the related posts stay together.

Hopefully Moty's reply addresses your question. If not, then you should
probably be more specific about what exactly is in the way here. Are you
having trouble actually reading the data, as your most recent posts
suggests? Or is there something else about the desired goal you're having
trouble implementing? If so, what exactly is it that you're trying and
not having success with?

Pete
Jun 3 '07 #3
On Jun 3, 9:35 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Sun, 03 Jun 2007 07:58:06 -0700, gator <glb...@gmail.c omwrote:
I am quite new to XML and posted a request for example code yesterday.
Unfortunately, I did not do a very good job in explaining what I was
looking for. Here is an example of a small piece of the file:

. [...]
How could I loop through a specific node, such as "Scoreboard/Teams"
and pull out all the information for ONLY that specific node? Once
that is done I would like to be able to move to another node such as
"Match/Teams" and loop through only that node and get all the info. I
would not need to loop through every node in the file, just specific
ones.

There is no need to start a new thread, or even to repost the sample
data. If you feel that you should elaborate or clarify the original post,
you can and should simply reply in that original thread, so that all of
the related posts stay together.

Hopefully Moty's reply addresses your question. If not, then you should
probably be more specific about what exactly is in the way here. Are you
having trouble actually reading the data, as your most recent posts
suggests? Or is there something else about the desired goal you're having
trouble implementing? If so, what exactly is it that you're trying and
not having success with?

Pete
Use
XmlDataDocument xmlDoc = new XmlDataDocument ();
xmlDoc.Load("Sa mple.xml"); //or use xmlDoc.LoadXml( xmlData);//xmlData
is string
XmlNode myNode =xmlDoc.SelectS ingleNode(""/mytable/myrow");//modify
path according to ur xml schema
Now you can use:
foreach (XmlNode fieldNode in myNode.ChildNod es)
{
}

I guess Moly has given the right thing for you. This'd be pretty easy
for you. Good luck!

Jun 3 '07 #4
<snipped>
>
Please if anyone has an example on how to do this, I would really
appreciate it. I am in urgent need of getting this done immediately.
You mean to sit there and say that you cannot go out to Google and find
examples on how to do this and put two and two together?

You mean to say that you have to post to a NG and be crutched along, because
you're too lazy to go find an example of this yourself? :)

Jun 3 '07 #5
On Sun, 03 Jun 2007 13:34:52 -0700, Mr. Arnold <MR. <Ar****@Arnold. com>>
wrote:
[abusive reply snipped] :)
Honestly. How does putting a smiley at the end of that post make it okay?

Most of the questions that are answered here could be addressed through
just reading the MSDN documentation, or experimenting with the API. I
don't think that justifies writing hostile replies such as yours when
someone posts such a question.

I have to admit, I have a hard time understanding the question, because it
looks like a pretty straightforward task to me. But I accept that not
everyone can "see" the solution right away, nor do I always "see" the
solution right away. It's a matter of perspective and sometimes what
seems like a dumb question really just needs someone to figure out what's
wrong with the poster's perspective and help them work their way to a
different point of view.

Regardless, I don't think that harassing someone just because they asked a
question is reasonable.

Pete
Jun 3 '07 #6

There you go again trying put your spin on what I was saying. You simply
need to mind your own business and stay out of mine.

Jun 3 '07 #7
On Jun 3, 5:17 pm, "Mr. Arnold" <MR. Arn...@Arnold.c omwrote:
There you go again trying put your spin on what I was saying. You simply
need to mind your own business and stay out of mine.
What is wrong with you? If you don't like my question ... don't
answer it. You told that guy to mind his own business, why don't you
take your advice and stay out of mine.

Jun 3 '07 #8
On Jun 3, 1:08 pm, Aneesh P <anees...@gmail .comwrote:
On Jun 3, 9:35 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:


On Sun, 03 Jun 2007 07:58:06 -0700, gator <glb...@gmail.c omwrote:
I am quite new to XML and posted a request for example code yesterday.
Unfortunately, I did not do a very good job in explaining what I was
looking for. Here is an example of a small piece of the file:
. [...]
How could I loop through a specific node, such as "Scoreboard/Teams"
and pull out all the information for ONLY that specific node? Once
that is done I would like to be able to move to another node such as
"Match/Teams" and loop through only that node and get all the info. I
would not need to loop through every node in the file, just specific
ones.
There is no need to start a new thread, or even to repost the sample
data. If you feel that you should elaborate or clarify the original post,
you can and should simply reply in that original thread, so that all of
the related posts stay together.
Hopefully Moty's reply addresses your question. If not, then you should
probably be more specific about what exactly is in the way here. Are you
having trouble actually reading the data, as your most recent posts
suggests? Or is there something else about the desired goal you're having
trouble implementing? If so, what exactly is it that you're trying and
not having success with?
Pete

Use
XmlDataDocument xmlDoc = new XmlDataDocument ();
xmlDoc.Load("Sa mple.xml"); //or use xmlDoc.LoadXml( xmlData);//xmlData
is string

XmlNode myNode =xmlDoc.SelectS ingleNode(""/mytable/myrow");//modify
path according to ur xml schema

Now you can use:
foreach (XmlNode fieldNode in myNode.ChildNod es)
{

}

I guess Moly has given the right thing for you. This'd be pretty easy
for you. Good luck!- Hide quoted text -

- Show quoted text -
Thanks to all for the help ... it's really appreciated.

- Steve

Jun 3 '07 #9

"Mark Rae" <ma**@markNOSPA Mrae.netwrote in message
news:eN******** ******@TK2MSFTN GP06.phx.gbl...
"Mr. Arnold" <MR. Ar****@Arnold.c omwrote in message
news:Op******** ******@TK2MSFTN GP05.phx.gbl...
>There you go again trying put your spin on what I was saying. You simply
need to mind your own business and stay out of mine.

Seems like good advice for everyone - <plonk>
I agree <Plank>. <g>

Jun 3 '07 #10

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

Similar topics

1
2611
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for topics to include in a course on object-orientation that I'm going to conduct. (I will later summarize all the replies and discussion, for the
2
2850
by: csx | last post by:
Hi all, I'm trying to count the number of leafnodes for a particular node. What im trying to do is make a function, that taking the tree structure: key row desc parent 1 1 A 0 2 2 B 1 3 2 C 1 4 3 D 3
2
6497
by: Claire Reed | last post by:
Dear All, I am repeatedly encountering a problem whilst looping through XML Nodes and I am unsure as to what is going on and how I can get around it. I load the following XML document into an XmlDocument object using LoadXml: <?xml version="1.0" encoding="UTF-8"?>
4
1313
by: Shapper | last post by:
Hello, I have a XML file that includes the node <item>: .... <title>...</title> <url>...</url> <item> <title>title 01</title> <description>description 01</description> </item>
2
2596
by: pmcguire67 | last post by:
There has been a lot of discussion lately about extending the treeview control to allow finding a node by key rather than by index. Everyone seems to agree that a hashtable is needed to accomplish this. Also, there is a KB article (http://support.microsoft.com/default.aspx?scid=kb;en-us;311318) purporting to show you how to extend the treenode to include a key. This article seems to be nearly useless to me, as (despite adding a...
12
291
by: **Developer** | last post by:
Dim tvn As TreeNode For Each tvn In rootNode.Nodes ....SNIP rootNode.Nodes.Remove(tvn) Next
1
9658
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
9
1915
by: TF | last post by:
Hello all, I made a ASP.NET 2.0 site that shows possible "recipes" for paint colors stored in an access dbase. Basically, 1000 colors are stored with specific RGB values in separate columns. A user sees all the colors listed on the page with hyperlinks that open the "mixes" page. The mixes page goes through each record, compares it with all other records in a ratio up to "maxratio". If it finds a ratio that matches the redvalue of...
6
2281
by: fido19 | last post by:
Once upon a time, there lived a chimpanzee called Luycha Bandor (aka Playboy Chimp). Luycha was unhappily married to Bunty Mona, a short but cute little lady chimp. Luycha was tall and handsome – he was feeling uncomfortable taking Bunty to public places along with him. People would stare at them all the while. At one point, Luycha could not stand it anymore and he decided to do some justice to his name. He started looking for a new hope in...
0
9543
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10488
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10029
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.