473,782 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML parsing in C#

I have a XML file like as follow

<?xml version="1.0" encoding="UTF-8"?>
<NeuStarLSRRepo rt>
<NeuStarHeade r fromDate="09/10/04" toDate="09/13/04"
RequestsReceive d ="43" ResponsesSent=" 50">
</NeuStarHeader>
<NeuStarReqestL ist>
<NeuStarRequest Recieved pon="IDT2345611 " ver="AA"
dateReceived="0 9/10/04" />
<NeuStarRequest Recieved pon="IDT2345615 " ver="AA"
dateReceived="0 9/10/04" />
</NeuStarReqestLi st>
<NeuStarRespons eList>
<NeuStarRespons eSent pon="IDT2345611 " ver="AA"
dateSent="09/10/04" MessageType="Er ror"/>
<NeuStarRespons eSent pon="IDT2345622 " ver="AB"
dateSent="09/10/04" MessageType="Er ror"/>
</NeuStarResponse List>
</NeuStarLSRRepor t>
from the above XML i need to parse the nodes inside node
<NeuStarRequest List>
<NueStarRespons eList> node. Both these nodes can have 1 or more number
of child nodes as described below( in above example, its just 2 for
each of them, but they can more or less also)'
how do i part the attributes values and i need to store them in the
database. For each node in both the nodes(NeuStarRe questList and
NeuStarResponse List) i need to insert a row into database table
conatining appropriate fields

any help?

venky
Nov 12 '05 #1
1 6135
Well you can do the following (just one way of doing it, I'm sure there are
lots other)

1. First find the node that you want to process, you can simply do an this
XPath '//NeuStarLSRRepor t/NeuStarReqestLi st/NeuStarRequestR ecieved '. This
will give you the XmlNodeCollecti on that you want to process.

2. Loop through that collection for each node that you want to process. For
each node you can get the attributes list (using the .Attributes property).
And then for each attributes you can build your SQL string

3. Do step 1 and 2 for the NeuStarResponse List nodes.

"Venkat Chellam" wrote:
I have a XML file like as follow

<?xml version="1.0" encoding="UTF-8"?>
<NeuStarLSRRepo rt>
<NeuStarHeade r fromDate="09/10/04" toDate="09/13/04"
RequestsReceive d ="43" ResponsesSent=" 50">
</NeuStarHeader>
<NeuStarReqestL ist>
<NeuStarRequest Recieved pon="IDT2345611 " ver="AA"
dateReceived="0 9/10/04" />
<NeuStarRequest Recieved pon="IDT2345615 " ver="AA"
dateReceived="0 9/10/04" />
</NeuStarReqestLi st>
<NeuStarRespons eList>
<NeuStarRespons eSent pon="IDT2345611 " ver="AA"
dateSent="09/10/04" MessageType="Er ror"/>
<NeuStarRespons eSent pon="IDT2345622 " ver="AB"
dateSent="09/10/04" MessageType="Er ror"/>
</NeuStarResponse List>
</NeuStarLSRRepor t>
from the above XML i need to parse the nodes inside node
<NeuStarRequest List>
<NueStarRespons eList> node. Both these nodes can have 1 or more number
of child nodes as described below( in above example, its just 2 for
each of them, but they can more or less also)'
how do i part the attributes values and i need to store them in the
database. For each node in both the nodes(NeuStarRe questList and
NeuStarResponse List) i need to insert a row into database table
conatining appropriate fields

any help?

venky

Nov 12 '05 #2

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

Similar topics

8
9445
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $ Last-Modified: $Date: 2003/10/28 19:48:44 $ Author: A.M. Kuchling <amk@amk.ca> Status: Draft Type: Standards Track
2
3958
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home Canonicalpath-Directory4: \\wkdis3\ROOT\home\bwe\ You selected the file named AAA.XML getXmlAlgorithmDocument(): IOException Not logged in
16
2907
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed loaded into cache, the slideshow doesn't look very nice. I am not sure how/when to call the slideshow() function to make sure it starts after the preload has been completed.
0
4131
by: Pentti | last post by:
Can anyone help to understand why re-parsing occurs on a remote database (using database links), even though we are using a prepared statement on the local database: Scenario: ======== We have an schema (s1) on an Oracle 9i database with database links pointing to a schema (s2) on another Oracle 9i database.
9
4062
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics" portions of Babe Ruth page (http://www.baseballprospectus.com/dt/ruthba01.shtml) and store that info in a CSV file. Also, I would like to do this for numerous players whose IDs I have stored in a text file (e.g.: cobbty01, ruthba01, speaktr01, etc.)....
5
4307
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
3
4386
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
13
4515
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple command set consisting of several single letter commands which take no arguments. A few additional single letter commands take arguments:
7
2410
by: Daniel Fetchinson | last post by:
Many times a more user friendly date format is convenient than the pure date and time. For example for a date that is yesterday I would like to see "yesterday" instead of the date itself. And for a date that was 2 days ago I would like to see "2 days ago" but for something that was 4 days ago I would like to see the actual date. This is often seen in web applications, I'm sure you all know what I'm talking about. I'm guessing this...
1
4407
by: eyeore | last post by:
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or Stack code and parsing code my professor i does not like me using buffer reader on my code and my professor did even give me an example code for parsing as well as pop push top or Stack code and i don't know how to do this code into parsing and pop push...
0
9641
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, 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...
0
10313
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
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9944
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...
0
8968
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, 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...
0
5378
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
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.