Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 672525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:29:40+00:00 2026-05-14T00:29:40+00:00

I have a bit of xml file named Sample.xml which is shown below <?xml

  • 0

I have a bit of xml file named Sample.xml which is shown below

  <?xml version="1.0" encoding="ISO-8859-1"?>

<countries>

<country>
  <text>Norway</text>
  <value>N</value>
</country>

<country>
  <text>Sweden</text>
  <value>S</value>
</country>

<country>
  <text>France</text>
  <value>F</value>
</country>

<country>
  <text>Italy</text>
  <value>I</value>
</country>

</countries>

i have button named submit(button1).If i click that button i need to display the count(PartitionName=”AIX”) in a text box named textBox1, means How many PartitionName=”AIX” is belonging to Type=”NIC”

Can any one give me the c# code

I did like this,,but not able to get the answaer

private void button1_Click(object sender, EventArgs e)
    {
        XmlDocument doc1 = new XmlDocument();
        doc1.Load(@"D:\New Folder\WindowsFormsApplication3\WindowsFormsApplication3\Sample.xml");
        XmlNodeList a = doc1.GetElementsByTagName("AIX");
        textBox1.Text = a.Count.ToString();
    }
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:29:41+00:00Added an answer on May 14, 2026 at 12:29 am

    XmlDocument doc1 = new XmlDocument();
    doc1.Load(@”C:\Labs\test.xml”);

            XmlNodeList nodes = doc1.GetElementsByTagName("inv:Port");
            int count = 0;
            foreach (XmlNode childNode in nodes)
            {
                XmlNodeReader nodeReader = new XmlNodeReader(childNode);
    
                while (nodeReader.Read())
                {
                    if (nodeReader.GetAttribute("PartitionName") == "AIX")
                    {
                        count++;
                    }               
    
                }               
            }       
    
            Console.WriteLine("Count = {0}", count);
            Console.ReadLine();     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my problem: I have this XML file: <?xml version=1.0 encoding=utf-8 ?> <settings>
I have to read/write an XML file that stores its data as bit masked
I have a bit of Java code that outputs an XML file to a
I have an xml file which looked something like this... <RootElementTag> <ChildElementTag1 attribute1=value1 />
Good morning. I have an XML file which contains lists of warning and errors
I have a directory, d:/resources/xxxxx/file-name.xxx that stores the file types: .png, .xml, .pdf, which
Bit of a beginner question here: Say I have a block of xml: <root>
Right, bit of a strange question; I have been doing some linq to XML
I have an XML Schema that mostly makes sense, but I encountered a bit
I have the following xml sample: <items> <item> <item_id>1</item_id> <item_name>item 1</item_name> <group_id>1</group_id> <group_name>group 1</group_name>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.