473,499 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parsing XML Data using a C# Windows Application

5 New Member
Hello all. I posted this in the .NET forum , but as it spans both groups I thought it might be best if I posted here too.

I'm trying to parse data stored in XML format into my Windows application using C#. I'd like specific XML Nodes listed in a TreeView. When the TreeView Nodes are clicked I need corresponding XML data displayed in a different panel in the application using perhaps a DataGridView.

Currently I have the TreeView part working. But I think I might be doing it inefficiently. I'm currently just traversing each XML Node through it's ChildNodes (using foreach loops) adding XML Nodes to the TreeView when appropriate. This works, but I'm afraid it might be slow on a large file.

What I really need help on is getting the correct data to display in the DataGridView. If the XML looks like this:

Expand|Select|Wrap|Line Numbers
  1. <CustomerOrders>
  2.   <Customers>
  3.     <CustomerID>ALFKI</CustomerID>
  4.     <Orders>
  5.       <OrderID>10643</OrderID>
  6.       <CustomerID>ALFKI</CustomerID>
  7.       <OrderDate>1997-08-25T00:00:00</OrderDate>
  8.     </Orders>
  9.     <Orders>
  10.       <OrderID>10692</OrderID>
  11.       <CustomerID>ALFKI</CustomerID>
  12.       <OrderDate>1997-10-03T00:00:00</OrderDate>
  13.     </Orders>
  14.     <CompanyName>Alfreds Futterkiste</CompanyName>
  15.   </Customers>
  16.   <Customers>
  17.     <CustomerID>ANATR</CustomerID>
  18.     <Orders>
  19.       <OrderID>10308</OrderID>
  20.       <CustomerID>ANATR</CustomerID>
  21.       <OrderDate>1996-09-18T00:00:00</OrderDate>
  22.     </Orders>
  23.     <CompanyName>Ana Trujillo Emparedados y helados</CompanyName>
  24.   </Customers>
  25. </CustomerOrders>
The TreeView Nodes will be:
CustomerOrders
--Customers
----Orders
----Orders
--Customers
----Orders

When the user clicks on the first Customers Node, I'd like both Orders for that Customers displayed in the DataGridView. If the user clicks on on a specific Order, just that Order is displayed. If the user clicks on CustomerOrders, all Orders for all Customers will be displayed.

I'm currently trying to load the XML file into a DataSet, then get the correct data from the DataSet into a DataTable, and then bind that DataTable to the DataGridView. But I can't seem to get that to work.

I'm curious if this would be easier if I created an XML Schema to go along with it. What would an appropriate Schema look like (I'm studying them now)?

All help welcome, thanks, sorry this is so long.
Aug 22 '07 #1
0 1531

Sign in to post your reply or Sign up for a free account.

Similar topics

2
7330
by: MK | last post by:
I have a Win32 console application (SNMPUTIL.EXE) which listens to incoming SNMP messages: C:\>snmputil trap snmputil: listening for traps... When a trap is generated on a remote server, it...
8
4569
by: Garyrek | last post by:
Hi I have an url where I have xml data POSTED and I need to parse the URL to read the data - Meanwhile here is my xml data =================================== <?xml version="1.0"...
0
2109
by: cpavon | last post by:
Hello everyone, I am fairly new to MACT, I am currently trying to parse the oResponse.Body to retrive a dynamic values...store in an array and then randomly post those values. Does anyone...
3
3481
by: Pir8 | last post by:
I have a complex xml file, which contains stories within a magazine. The structure of the xml file is as follows: <?xml version="1.0" encoding="ISO-8859-1" ?> <magazine> <story>...
1
1870
by: sp | last post by:
i have an xml file (an rss file) <?xml version="1.0" ?> <rss version="2.0"> <channel> <title>CodeGuru.com</title> <link>http://www.codeguru.com/</link> <description>The number one developer...
5
4280
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
2
14703
by: Cuong.Tong | last post by:
Greeting, Can anyone give me some hints about parsing the mulitpart/form-data stream? I have a form looks something like this <form action="process.dll> <input type=file...
3
17233
by: Cuong.Tong | last post by:
Greeting, I am writing my own web server and having some problme parsing the the mulitpart/form-data stream that is sent from the browsers. I have a form looks something like this <form...
3
4358
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
1
1927
by: doug9149 | last post by:
Hello all. I'm trying to parse data stored in XML format into my Windows application using C#. I'd like specific XML Nodes listed in a TreeView. When the TreeView Nodes are clicked I need...
0
7132
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
7009
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...
1
6899
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
5475
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,...
1
4919
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...
0
4602
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
3103
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...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
302
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...

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.