<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'how to display parent node attribute name in xmlDocument' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'how to display parent node attribute name in xmlDocument' posted on the 'C#' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 25 May 2013 09:37:20 -0700</pubDate>
    <lastBuildDate>Sat, 25 May 2013 09:37:20 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>how to display parent node attribute name in xmlDocument</title>
      <link>http://www.programmersheaven.com/mb/csharp/421805/421805/how-to-display-parent-node-attribute-name-in-xmldocument/</link>
      <description>hi, im trying to display the attribute name of the parent node once the input matches a town name:&lt;br /&gt;
&lt;br /&gt;
my xml is:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
&amp;lt;phonebook&amp;gt; 
  &amp;lt;area code="022"&amp;gt; 
    &amp;lt;town&amp;gt;mallow&amp;lt;/town&amp;gt; 
  &amp;lt;/area&amp;gt; 
  &amp;lt;area code="023"&amp;gt; 
    &amp;lt;town&amp;gt;bandon&amp;lt;/town&amp;gt; 
    &amp;lt;town&amp;gt;bray&amp;lt;/town&amp;gt;      
  &amp;lt;/area&amp;gt; 
  &amp;lt;area code="024"&amp;gt; 
    &amp;lt;town&amp;gt;youghal&amp;lt;/town&amp;gt;     
  &amp;lt;/area&amp;gt; 
  &amp;lt;area code="025"&amp;gt; 
    &amp;lt;town&amp;gt;fermoy&amp;lt;/town&amp;gt;     
  &amp;lt;/area&amp;gt; 
&amp;lt;/phonebook&amp;gt; 

&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
my method is:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
private void btnGetNum_Click(object sender, EventArgs e) 
{ 
 XmlNodeList towns = doc.GetElementsByTagName("town"); 
   foreach (XmlNode town in towns) 
   { 
      if (txtInput.Text.Equals(town.ChildNodes[0].Value)) 
      { 
       lstResult.Items.Add("area code is" +  ??????????); 
   } 
} 

&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/csharp/421805/421805/how-to-display-parent-node-attribute-name-in-xmldocument/</guid>
      <pubDate>Thu, 17 Feb 2011 07:39:05 -0700</pubDate>
      <category>C#</category>
    </item>
    <item>
      <title>Re: how to display parent node attribute name in xmlDocument</title>
      <link>http://www.programmersheaven.com/mb/csharp/421805/421983/re-how-to-display-parent-node-attribute-name-in-xmldocument/#421983</link>
      <description>Try this:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
town.ParentNode.Attributes.GetNamedItem("code").Va
lue
&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/csharp/421805/421983/re-how-to-display-parent-node-attribute-name-in-xmldocument/#421983</guid>
      <pubDate>Thu, 24 Feb 2011 14:33:53 -0700</pubDate>
      <category>C#</category>
    </item>
  </channel>
</rss>