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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:31:53+00:00 2026-05-27T19:31:53+00:00

I want to read the following xml using c#. <configuration> <configSections> <sectionGroup name=spring> <section

  • 0

I want to read the following xml using c#.

<configuration>
  <configSections>
    <sectionGroup name="spring">
      <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
      <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
    </sectionGroup>
  </configSections>
  <spring>
    <context>
      <resource uri="config://spring/objects" />
    </context>
    <objects xmlns="http://www.springframework.net">
<object></object>
</objects>
</spring>
</configuration>

It wont identify xmlns from objects node.

string xmlFile = @"App1.config";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlFile);
XmlNodeList nodeList = xmlDoc.SelectNodes("configuration/spring/objects/object");
foreach (XmlElement xmlElement in nodeList)
{
    string id = xmlElement.GetAttribute("id");  //Output - SimulatorControlTCP
    XmlNodeList xmlPropertyNodeList = xmlElement.SelectNodes("property");
    foreach (XmlElement xmlPropertyElement in xmlPropertyNodeList)
    {
        id = xmlPropertyElement.GetAttribute("value");
        if ((id.Contains("tcp") || id.Contains("http")) && id.Contains("localhost"))
        {
            id = id.Replace("localhost","1.1.1.1");
            xmlPropertyElement.Attributes[1].Value = id;
            xmlDoc.Save(xmlFile); 
        }
    }

}

It won’t go inside foreach loop. If I remove xmlns , then the above code works fine.

  • 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-27T19:31:54+00:00Added an answer on May 27, 2026 at 7:31 pm

    one way:

                DataSet ds = new DataSet();
                ds.ReadXml(Server.MapPath("YourFile.xml"));
                GridView1.DataSource = ds;
                GridView1.DataBind();
    

    Next way:

    <asp:Xml ID="Xml1" runat="server" DocumentSource="~/XML/XMLFile.xml">
        </asp:Xml>
    

    For more about 2nd method see
    http://www.codeproject.com/KB/aspnet/ASPNET_20_XMLControl.aspx

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

Sidebar

Related Questions

I am using the following XML structure <SERVERS> <SERVER NAME=A1 ID=1></SERVER> <SERVER NAME=A2></SERVER> <SERVER
I want to read whatever is inside the <q:content></q:content> tags in the following xml
I want to read the following XML file received from my e-commerce site and
I want to read a XML file, using XMLReader but the END ELEMENT is
I am using PHP and simpleXML to read the following rss feed: http://feeds.bbci.co.uk/news/england/rss.xml I
I have the following XML file with page nodes which I want to read
I want to read xml file which looks like the following ... I have
What I want to do is the following: read in multiple line input from
I want to run the following command from a C program to read the
I want to read and write from serial using events/interrupts. Currently, I have it

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.