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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:51:25+00:00 2026-05-20T17:51:25+00:00

How to access an XML file in C#? How to count the number of

  • 0

How to access an XML file in C#?
How to count the number of nodes in that xml file?
How am i supposed to access each and every node in that xml file?

I have two xml files, one of them is dev.xml which has this code

<Devanagri_to_itrans>
  <mapping>
    <character>अ</character>
    <itrans>a</itrans>
  </mapping>
  ...
</Devanagri_to_itrans>

the second file is guj.xml (with a very similar structure)

<Gujrathi_to_itrans>
  <mapping>
     <character>અ</character>
     <itrans>a</itrans>
  <mapping>
  ...
</Gujrathi_to_itrans>

I need to turn this into a two-dimension arraying of the character mappings.

  • 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-20T17:51:26+00:00Added an answer on May 20, 2026 at 5:51 pm

    Since you’ve added more details I can now provide a better answer.
    Here is a functional xml parsing and joining console app that demonstrates what it is you’re looking for (I think). To parse xml files rather than xml strings use the XDocument Load method rather than the displayed Parse method. Good luck,

                XDocument docA = XDocument.Parse(
    @"<Devanagri_to_itrans>
      <mapping>
        <character>अ</character>
        <itrans>a</itrans>
      </mapping>
    </Devanagri_to_itrans>");
                XDocument docB = XDocument.Parse(
    @"<Gujrathi_to_itrans>
      <mapping>
         <character>અ</character>
         <itrans>a</itrans>
      </mapping>
    </Gujrathi_to_itrans>");
                var devanagriKeys = (from d in docA.Descendants("mapping")
                                                      select new {
                                                          Key = d.Descendants("itrans").FirstOrDefault().Value,
                                                          Character = d.Descendants("character").FirstOrDefault().Value
                                                      }).ToArray();
                var gujrathiKeys = (from g in docB.Descendants("mapping")
                                                      select new {
                                                          Key = g.Descendants("itrans").FirstOrDefault().Value,
                                                          Character = g.Descendants("character").FirstOrDefault().Value
                                                      }).ToArray();
                var crossReference = (from d in devanagriKeys
                                      join g in gujrathiKeys on d.Key equals g.Key
                                      select new {
                                            d.Key,
                                            Devanagri = d.Character,
                                            Gujrathi = g.Character
                                        }).ToList();
                Console.WriteLine("Enter a key character to translate:");
                string searchKey = Console.ReadLine();
                var translation = crossReference.Where(cr => cr.Key == searchKey).FirstOrDefault();
                if (translation == null) 
                    Console.WriteLine("No such key in the cross reference.");
                else
                    Console.WriteLine("{0} is {1} in Devanagri and {2} in Gujrathi", 
                        translation.Key, translation.Devanagri, translation.Gujrathi);
                Console.ReadKey(true);
    

    PER REQUEST FOR SESSION VARIABLE:

    Anonymous types are only intended for use within a method. To place a list into a Session variable for use elsewhere create a real class of your own that contains the 3 desired properties and change the line of code above very matching this to the below. (The class name I chose was CrossReferenceTranslation.)

            Session["CrossReference"] = (from d in devanagriKeys
                                  join g in gujrathiKeys on d.Key equals g.Key
                                  select new CrossReferenceTranslation() {
                                        d.Key,
                                        Devanagri = d.Character,
                                        Gujrathi = g.Character
                                    }).ToList();
    

    …then, at some other point in time you can do this to get your session object list into a variable. Note the assumption that the variable could be null, which would happen whenever a session has timed out…

    List<CrossReferenceTranslation>() crossReference = Session["CrossReference"] ?? 
       new List<CrossReferenceTranslation>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two xml files, one of them is dev.xml which has this code
I have an XML file that I want to access in an Windows Phone
I have an XML file that I want to be able to access the
I have a .xml file in my App_Data folder, I can access it fine
I've got an XML file on my server, and my partners have to access
I have a windows service which is trying to access an xml file from
I have a basic XML file that I load in my PHP using $xml
I am trying to access an XML file from JSP on my Tomcat server.
I'm trying to access an xml file over http. The address is similar to:
I need to access the struts.action.extension value in the struts.xml file from an interceptor.

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.