473,851 Members | 2,207 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'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:

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.

All help welcome, thanks, sorry this is so long.
Aug 22 '07 #1
1 1948
5 New Member
Anybody? I suppose I'll ask this in the XML section as well.

I'm curious if this would be easier if I created an XML Schema to go along with it.
Aug 22 '07 #2

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

Similar topics

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 is being sent to the PC running SNMPUTIL.EXE, and then finally printed out to stdout like this:
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" encoding="utf-16"?> <?adf version="1.0"?> <!DOCTYPE adf SYSTEM "http://whoscalling.com/dtd/adfdtd.dtd"> <adf> <prospect status="new">
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 have any sample code on how to parse the oResponse.Body? This is what I have so far but I cannot seem to get the value I'm trying to pick up.
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 site!</description> <language>en-us</language> <lastBuildDate>Mon, 13 Feb 2006 09:52:05 EST</lastBuildDate>
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
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 name=fileupload</input> </form>
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 action="process.dll>
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 the file) with the location. And for a particular section I parse only that section. The file is something like, .... DATAS
by: doug9149 | last post by:
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...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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,...
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...
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...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.