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 8322021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:13:57+00:00 2026-06-08T23:13:57+00:00

i am trying search data in xml file. if found, it will popup MessageBox

  • 0

i am trying search data in xml file. if found, it will popup MessageBox and display all the data found.

this is my code.

DataView dv;
        DataSet ds = new DataSet();
        ds.ReadXml("C:\\Users\\HDAdmin\\Documents\\SliceEngine\\SliceEngine\\bin\\Debug\\saya.xml");
        dv = new DataView(ds.Tables[0]);
        dv.Sort = "Name";
        int index = dv.Find("Name");
        if (index == -1)
        {
            MessageBox.Show("Item Not Found");
        }
        else
        {
            MessageBox.Show(dv[index]["Name"].ToString()); 
        }

but it always said the item not found.

then i tried to do this.

    XmlDocument xml = new XmlDocument();            
            xml.Load("C:\\Users\\HDAdmin\\Documents\\SliceEngine\\SliceEngine\\bin\\Debug\\saya.xml");
            XmlNodeList xnList = xml.SelectNodes("/Patient/Patient/Name");
            foreach (XmlNode xn in xnList)
            {
                string name = xn["Name"].InnerText;
                listBox21.Items.Add(name);
}

for this code, i tried to put it into the listbox. by doing this, it said that it is a null object.

below is my xml file.

    <Patient>
       <Patient>
         <Level>0</Level>
         <Name>w</Name>
         <Gender>0</Gender>
      </Patient>
   </Patient>

can anybody help me with this.

  • 1 1 Answer
  • 0 Views
  • 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-06-08T23:14:00+00:00Added an answer on June 8, 2026 at 11:14 pm

    You have to consider your code is ok! But here’s the problem:

    xn["Name"].InnerText
    

    Becase xn represents /Patient/Patient/Name and you just need to do:

    xn.InnerText
    

    to get its value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to search for data in a XML File using php. I'm not
I am thinking of storing bunch of data in XML files. Each file will
I'm trying to parse data from Archive.org's search functionality. The data looks like this:
I'm trying to take some parsed XML data, search it for instances of the
I am trying to search a MongoDB database filtering on a specific data item.
I'm trying to do a location-based search on App Engine, but since the data
I'm trying to search through many documents and find all instances where an html
So I am trying to retrieve data from an XML stream coming from a
So i am trying to make a function that searches trough an xml file,
I'm trying to parse Reddit's XML file with javascript and im having trouble retrieving

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.