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

Parse XML using C#

snehil
19
I have an xml like

Expand|Select|Wrap|Line Numbers
  1. <?xml version='1.0' encoding='UTF-8'?>
  2.     <feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:docs='http://schemas.google.com/docs/2007' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;C0EARXY8eit7ImA9WhVREE0.&quot;'>
  3.  
  4.     <id>https://docs.google.com/feeds/default/private/full</id>
  5.     <updated>2012-03-17T16:27:24.872Z</updated>
  6.     <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/docs/2007#item' label='item'/>
  7.  
  8.     <title>Available Documents - </title>
  9.  
  10.     <link rel='alternate' type='text/html' href='https://docs.google.com'/>
  11.     <link rel='http://schemas.google.com/g/2005#resumable-create-media' type='application/atom+xml' href='https://docs.google.com/feeds/upload/create-session/default/private/full'/>
  12.     <link rel='http://schemas.google.com/docs/2007#alt-post' type='application/atom+xml' href='https://docs.google.com/feeds/upload/file/default/private/full'/>
  13.     <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full'/>
  14.     <link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full'/>
  15.     <link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full/batch'/>
  16.     <link rel='self' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full/-/document'/>
  17.  
  18.     <some more tags />
  19.  
  20.     <entry gd:etag='&quot;E0UXTh9YDSt7ImBr&quot;'>
  21.     <some more tags />
  22.     <title>hi</title>
  23.     <link rel='http://schemas.google.com/docs/2007#parent' type='application/atom+xml' href=''/>
  24.     <link rel='alternate' type='application/atom+xml' href=''/>
  25.     <link rel='http://schemas.google.com/docs/2007#embed' type='application/atom+xml' href=''/>
  26.     <link rel='http://schemas.google.com/docs/2007#icon' type='application/atom+xml' href=''/>
  27.     <link rel='http://schemas.google.com/g/2005#resumable-edit-media' type='application/atom+xml' href=''/>
  28.     <link rel='http://schemas.google.com/docs/2007#alt-edit-media' type='application/atom+xml' href=''/>
  29.     <link rel='http://schemas.google.com/docs/2007/thumbnail' type='application/atom+xml' href=''/>
  30.     <link rel='self' type='application/atom+xml' href=''/>
  31.     <link rel='edit' type='application/atom+xml' href=''/>
  32.     <link rel='edit-media' type='application/atom+xml' href=''/>
  33.     ...
  34.     <some more tags />
  35.     ...
  36.     </entry>
  37.     <entry>
  38.     ...
  39.     </entry>
  40.     ...
I want to fetch The attribute "href" of the element <link> whose rel="http://schemas.google.com/g/2005#resumable-create-media"

What I'm doing right now is I'm getting list of nodes with xmlnode = doc.GetElementsByTagName("link"); then I'm iterating throught all of them and fetching the first one whose rel="http://schemas.google.com/g/2005#resumable-create-media"

So essentially m looping through all the nodes <link> when I'm just interested in those which are next child of node <feed> and are not inside node <entry>
A <feed> have multiple <entry> nodes which inturn have multiple<link> tags..
And instead I would like to just get the list of <link> which are directly in <feed> and not in <entry>
Any help would be appreciated..
Mar 18 '12 #1
1 2707
Frinavale
9,735 Expert Mod 8TB
I think that you should probably use the XmlDocument class to help you manage the XML. Once you load the XML document into this class, it creates nodes that you work with. You should be able to access the attributes that you are looking for through the nodes.

It sounds like you are already on the right track.

-Frinny
Mar 19 '12 #2

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

Similar topics

0
by: precious | last post by:
i'm trying to split my xml configuration file to files implementing the parsing using xerces in java (DOMparser). my project uses a "fromXML" parsing design and here's what i tried in the node...
2
by: KB | last post by:
Hi folks, I'm trying to adopt microsoft-specific code to mozilla. I have an xml file which I can't figure out how to parse using the XMLDocument object: <?xml version="1.0" encoding="utf-16"...
24
by: | last post by:
Hi, I need to read a big CSV file, where different fields should be converted to different types, such as int, double, datetime, SqlMoney, etc. I have an array, which describes the fields and...
10
by: Reiner Merz | last post by:
Hi, I'm looking for advice on how to parse a timestamp string according to the ISO 8601 specification. For those unfamiliar with the standard, here's an example: 2003-09-09T23:00:00Z...
7
by: memememe | last post by:
I need to be able to parse both of these dates with the same method, and return them as a DateTime object. Is there any methods that would do this blindly or do I need to provide the format? Feb...
7
by: David Lozzi | last post by:
I need to support multiple keyword search, not boolean searchs, just simple searches, i.e. "marhsall ma". How is this done? Do I send the entire search string to the Proc? How do I deal with it...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
0
by: sumelong | last post by:
Hi all, i have an xsl with params to be parse using c#. I then used xslArgumentList and XpathNavigator Classes. I tried the following: 1-trans.transform(doc,params,writer,null). I had am empty...
9
by: seberino | last post by:
I'm a compiler newbie and curious if Python grammar is able to be parsed by a recursive descent parser or if it requires a more powerful algorithm. Chris
1
by: digidave | last post by:
I am keenly aware that my coding skills are extremely noob but please indulge me a second.. Take a look at these queries.. $sql = "SELECT DISTINCT year FROM _current_floats_config WHERE active =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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
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...

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.