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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:59:38+00:00 2026-06-09T08:59:38+00:00

I need to create an xml file that is supposed to look like this.

  • 0

I need to create an xml file that is supposed to look like this.

<Event id="Date - Event Name - Event Type">      
    <DogNumber id="dog id number">           
        <dogName id-"dog id number">dog name</dogName>               
        <dogBreed>dog breed</dogBreed>      
    </DogNumber>
</Event>

and then it would repeat again for another event except for different values and attributes for the elements.

<Event id="Date - Event Name - Event Type">      
    <DogNumber id="dog id number">           
        <dogName id-"dog id number">dog name</dogName>               
        <dogBreed>dog breed</dogBreed>      
    </DogNumber>
</Event>

I am new to creating XML files with C# and am having trouble properly adding the attributes to the element and getting the parent and child nodes the same as I have shown above. I need to be able to look into this file from my C# application and be able to read all of the values listed above based on the particular event and then the particular dog in each event. The criteria of which event and which dog to select will be based upon user input in a ComboBox likely. my plan was to use the getElementById method. However, I have seen so many different ways to do this that I am having trouble deciding what would be the best and most efficient way to do 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-09T08:59:40+00:00Added an answer on June 9, 2026 at 8:59 am

    I think easiest method to read/write that xml file would be using XMLSerializer. This approach also enable You to easly bind to data (if You are using WPF for UI)

    Create serializable classes:

        public class Event
        {
            [XmlAttribute]
            public string id { get; set; }
    
            [XmlElement]
            public DogNumber DogNumber { get; set; }
        }
    
        public class DogNumber
        {
            [XmlAttribute]
            public string id { get; set; }
    
            [XmlElement]
            public dogName dogName { get; set; }
    
            [XmlElement]
            public string dogBreed { get; set; }
        }
    
        public class dogName
        {
            [XmlAttribute]
            public string id { get; set; }
    
            [XmlTextAttribute]
            public string value { get; set;  }
        }
    

    and then use XmlSerializer to deserialize(example using file):

            Stream input = File.OpenRead("C:\\test.xml");
            XmlSerializer serialier = new XmlSerializer(typeof(Event));
            Event newevent = serialier.Deserialize(input) as Event;
            input.Close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create program that creates a XML schema like below using System.Xml.XmlSchema
I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
I need to create a new XML file and write that to my server.
I need to create an XML schema definition (XSD) that describes Java objects. I
I need to create a web service that returns XML data to some of
I need to create a WAR file that just contains static content files (gifs,
I have a very large XML file that I need to parse so I
I need to create a PHP script that receives XML input via an HTTP
I need to create an xml file here bool result= false; How to achieve
I have a small requirement where I need to create a XML file on

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.