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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:31:56+00:00 2026-05-16T04:31:56+00:00

I am using the following XML structure <SERVERS> <SERVER NAME=A1 ID=1></SERVER> <SERVER NAME=A2></SERVER> <SERVER

  • 0

I am using the following XML structure

<SERVERS>
<SERVER NAME="A1" ID="1"></SERVER>
<SERVER NAME="A2"></SERVER>
<SERVER NAME="A3" ID="3" Parent="XYZ"></SERVER>
<SERVER NAME="A4" ID="4"></SERVER>
<SERVER NAME="A5" Parent="abc" value="10"></SERVER>
<SERVER NAME="A6"></SERVER>
</SERVERS>

I am accessing this xml file by using LINQ to XML in asp.net by using C#. I am able to access all the attributes of an XML node by explicitly specifying the name of the attribute. I want to write query on this xml file which reads all the attribute values of the xml node (In our example the node is SERVER) dynamically means I want to write the query which can read the read the value of the attribute Name & ID from first node, only name from second row, Name, ID & Parent from the third row , Name & ID from the fourth row, Name, Parent & Value from the fifth row & only Name from the sixth row without modifying the existing code every time. Once I add one of the attribute ( for example if I add the attribute ID in the sixth row ) in the above xml file then I dont need to modify my LINQ to XML query. My query should dynamically fetch the total number of attributes & display their values. Is their any way to do this ? Can you provide me the any code or link through which I can resolve the above issue ?

  • 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-16T04:31:57+00:00Added an answer on May 16, 2026 at 4:31 am

    The below code will print out all attributes of an element.

    XDocument doc = XDocument.Load("file.xml");
    foreach(var element in doc.Element("SERVER").Elements()) {
      System.Diagnostics.Debug.WriteLine("Node " + element.Name.LocalName + ":");
      foreach(var attribute in element.Attributes()) {
         System.Diagnostics.Debug.WriteLine("  " + attribute.Name.LocalName + ": " + attribute.Value);
      }
    }
    

    For this XML:

    <SERVER>
     <ServerInstance ID="101" Name="Server1">
     <ServerInstance ID="102" Name="Server2">
    <SERVER>
    

    It will print out something like this:

    Node ServerInstance:
      ID: 101
      Name: Server1
    Node ServerInstance:
      ID: 102
      Name: Server2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 510k
  • Answers 510k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The variables you declare in db_login.php are globals. In order… May 16, 2026 at 4:54 pm
  • Editorial Team
    Editorial Team added an answer If the query is taking 10 minutes(!?!) you've got something… May 16, 2026 at 4:54 pm
  • Editorial Team
    Editorial Team added an answer The view is blank because the scene has been destroyed.… May 16, 2026 at 4:54 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an XML file of the following structure <Root> <Child Name=First> <Data Name=a
How can I fill RSA structure with xml-formatted public key for using with RSA
I have the following XML document that I have to parse using python's minidom:
From the following XML, I must extract the value of the uid attribute (557103888)
I am using the following code for the Share Price Application I have been
I am reading an XML file and reorganizing the desired data into Python data
I have the following XML <?xml version=1.0 encoding=ISO-8859-1?> <?xml-stylesheet type=text/xsl href=example3.xsl?> <pics> <page no=1>
I am trying to deploy a Maven site to an FTP server. I am
I am creating a Web Service using ASP.NET C#. I am sending various data
I know this is a probable open ended question, and I have tried looking

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.