Note that there are some explanatory texts on larger screens.

plurals
  1. POParse xml using c#
    text
    copied!<p>I have an xml like </p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;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/&amp;quot;C0EARXY8eit7ImA9WhVREE0.&amp;quot;'&gt; &lt;id&gt;https://docs.google.com/feeds/default/private/full&lt;/id&gt; &lt;updated&gt;2012-03-17T16:27:24.872Z&lt;/updated&gt; &lt;category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/docs/2007#item' label='item'/&gt; &lt;title&gt;Available Documents - &lt;/title&gt; &lt;link rel='alternate' type='text/html' href='https://docs.google.com'/&gt; &lt;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'/&gt; &lt;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'/&gt; &lt;link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full'/&gt; &lt;link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full'/&gt; &lt;link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full/batch'/&gt; &lt;link rel='self' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full/-/document'/&gt; &lt;some more tags /&gt; &lt;entry gd:etag='&amp;quot;E0UXTh9YDSt7ImBr&amp;quot;'&gt; &lt;some more tags /&gt; &lt;title&gt;hi&lt;/title&gt; &lt;link rel='http://schemas.google.com/docs/2007#parent' type='application/atom+xml' href=''/&gt; &lt;link rel='alternate' type='application/atom+xml' href=''/&gt; &lt;link rel='http://schemas.google.com/docs/2007#embed' type='application/atom+xml' href=''/&gt; &lt;link rel='http://schemas.google.com/docs/2007#icon' type='application/atom+xml' href=''/&gt; &lt;link rel='http://schemas.google.com/g/2005#resumable-edit-media' type='application/atom+xml' href=''/&gt; &lt;link rel='http://schemas.google.com/docs/2007#alt-edit-media' type='application/atom+xml' href=''/&gt; &lt;link rel='http://schemas.google.com/docs/2007/thumbnail' type='application/atom+xml' href=''/&gt; &lt;link rel='self' type='application/atom+xml' href=''/&gt; &lt;link rel='edit' type='application/atom+xml' href=''/&gt; &lt;link rel='edit-media' type='application/atom+xml' href=''/&gt; ... &lt;some more tags /&gt; ... &lt;/entry&gt; &lt;entry&gt; ... &lt;/entry&gt; ... </code></pre> <p>I want to fetch the attribute <code>href</code> of the element <code>&lt;link&gt;</code> whose <code>rel="http://schemas.google.com/g/2005#resumable-create-media"</code></p> <p>What I'm doing right now is I'm getting list of nodes with <code>xmlnode = doc.GetElementsByTagName("link");</code> then I'm iterating through all of them and fetching the first one whose <code>rel="http://schemas.google.com/g/2005#resumable-create-media"</code></p> <p>So essentially I'm looping through all the nodes <code>&lt;link&gt;</code> when I'm just interested in those which are next child of node <code>&lt;feed&gt;</code> and are not inside node <code>&lt;entry&gt;</code>. A <code>&lt;feed&gt;</code> have multiple <code>&lt;entry&gt;</code> nodes which in turn have multiple <code>&lt;link&gt;</code> tags. And instead I would like to just get the list of <code>&lt;link&gt;</code> which are directly in <code>&lt;feed&gt;</code> and not in <code>&lt;entry&gt;</code>.</p> <p>Any help would be appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload