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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:52:29+00:00 2026-05-31T14:52:29+00:00

I’m new to xml in .net, And I have this requirements that i need

  • 0

I’m new to xml in .net, And I have this requirements that i need to search in xml file. For example i have this xml file.

<?xml version="1.0" encoding="utf-8"?>
<Books>
  <Book>
    <Title>Sample book1</Title>
  </Book>
  <Book>
    <Title>Sample book2</Title>
  </Book>
  <Book>
<Title>Another book</Title>

And for example I use the word “sample” as search key so the output would be Sample book1 and Sample book2. and if I used “book” as search key, the output would be Sample book1,Sample book2 and Another book.

Base from what i have right now, it seems it’s not possible.

            Dim xmlDocument As New XmlDocument()
        Dim _xmlDataSource As New XmlDataSource

        xmlDocument.Load(Server.MapPath("XML/Books.xml"))

        Dim node = xmlDocument.DocumentElement.SelectSingleNode("./Books/Book[@title='SearchKey']")

Is this possible in .net? Can you review also if my xml file is in correct format base on the requirements.

Thanks in advance

  • 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-05-31T14:52:30+00:00Added an answer on May 31, 2026 at 2:52 pm

    I can show you example (you can use linq questions) This is my old project:

    var billings = from damskie in billingData.Element(“ubrania”).Element(“damska”).Element(“pm”).Descendants(“item”)
    select new dane_xml_panel((int)damskie.Element(“id”));

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.ComponentModel.DataAnnotations;
    using System.Xml.Linq;
    
    namespace sklep_internetowy_MVC.Models
    {
        public class pobierane_dane_xml 
        {
            private List<dane_xml_panel> allBillings;
            private XDocument billingData;
    
            // constructor
            public pobierane_dane_xml()
            {
    
                    allBillings = new List<dane_xml_panel>();
    
                    billingData = XDocument.Load(HttpContext.Current.Server.MapPath("~/App_Data/dane.xml"));
                    var billings = from damskie in billingData.Element("ubrania").Element("damska").Element("pm").Descendants("item")
                                   select new dane_xml_panel((int)damskie.Element("id"));
                    allBillings.AddRange(billings.ToList<dane_xml_panel>());
    
            }
    
            // return a list of all billings
            public IEnumerable<dane_xml_panel> GetBillings()
            {
                    return allBillings;
            }
    
    
            public dane_xml_panel GetBillingByID(int id)
            {
                    return allBillings.Find(item => item.ID == id);
            }
    
            // Insert Record
            public void InsertBilling(dane_xml_panel billing)
            {
                    billing.ID = (int)(from b in billingData.Descendants("item") orderby (int)b.Element("id") descending select (int)b.Element("id")).FirstOrDefault() + 1;
    
                    billingData.Root.Add(new XElement("item", new XElement("id", billing.ID)));
    
                    billingData.Save(HttpContext.Current.Server.MapPath("~/App_Data/dane.xml"));
            }
    
            // Delete Record
            public void DeleteBilling(int id)
            {
                    billingData.Root.Elements("item").Where(i => (int)i.Element("id") == id).Remove();
    
                    billingData.Save(HttpContext.Current.Server.MapPath("~/App_Data/dane.xml"));
            }
    
            // Edit Record
            public void EditBilling(dane_xml_panel billing)
            {
                XElement node = billingData.Root.Elements("item").Where(i => (int)i.Element("id") == billing.ID).FirstOrDefault();
    
    
                billingData.Save(HttpContext.Current.Server.MapPath("~/App_Data/dane.xml"));
            }
        }
    }
    

    Class

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.ComponentModel.DataAnnotations;
    
    
    namespace sklep_internetowy_MVC.Models
    {
        public class dane_xml_panel 
        {
              public dane_xml_panel()
            {
                this.ID = 0;
    
            }
    
              public dane_xml_panel(int id)
              {
                  this.ID = id;
              }
    
            public int ID { get; set; }
    
        }
    }
    

    and here you have got xml file(dane xml):

    <?xml version="1.0" encoding="utf-8"?>
    <ubrania>
        <damska>
            <nk id="Nowa Kolekcja">
    
                <item>
                        <id>1</id>
    
                </item>
                <item>
                        <id>2</id>
    
                </item>
    
            </nk>
            <pm id="Nowosci">
    
                <item>
                        <id>3</id>
    
                </item>
                <item>
                        <id>4</id>
    
                </item>
    
            </pm>
    
        </damska>
    
    
    </ubrania>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.