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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:08:59+00:00 2026-06-16T11:08:59+00:00

I try to Parse an XML file and collect from it the wanted value.

  • 0

I try to Parse an XML file and collect from it the wanted value. I’ve the following XML:

<?xml version="1.0"?>
<TDXItem>
    <PROJECT_NAME name="Project_MNG_Test">
            <PROJECT_ID>1022</PROJECT_ID>
            <DOMAIN_NAME>PROJECTS_MNG</DOMAIN_NAME>
            <DB_NAME>projects_mng_project_mng_test_</DB_NAME>
    </PROJECT_NAME>
    <PROJECT_NAME name="Project_MNG_Test1">
            <PROJECT_ID>1023</PROJECT_ID>
            <DOMAIN_NAME>PROJECTS_MNG</DOMAIN_NAME>
            <DB_NAME>projects_mng_project_mng_test1_</DB_NAME>
    </PROJECT_NAME>
</TDXItem>

and I tried versious of codes, most recent the below code:

public static void RunQuery(){
            string UserName = null;
            string xmlURI = "Sites_Name.xml";
            XDocument doc = XDocument.Load(xmlURI);
            var field = doc.Descendants("PROJECT_NAME").Where(x => (string)x.Attribute("name") == "PROJECT_MNG_Test").FirstOrDefault();
            if (field != null)
            {
        // Use value here                    
        string value = (string)field.Element("DB_NAME");

             }    
 }

but my value is getting null all the time, I tried a lot of convention noting work.
I know that it’s my bad, but i don’t know where, in my code or at the way I built the XML file.

  • 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-16T11:09:00+00:00Added an answer on June 16, 2026 at 11:09 am

    You shouldn’t specify a namespace here, for example use:

    var field = doc.Descendants("PROJECT_NAME")
       .Where(x => (string)x.Attribute("name") == "Project_MNG_Test").FirstOrDefault();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to parse this XML file (config file from Chirpy ): <?xml version=1.0
I try to parse articles from wikipedia. I use the *page-articles.xml file, where they
I have the following XML file: <?xml version=1.0 encoding=utf-8 ?> <strategies> <strategy name=God Class>
I have XML file. It's movie showtimes, and i try parse. <?xml version=1.0 encoding=UTF-8?>
I have an xml file with the following information. <?xml version=1.0?> -<Party> -<Player> <Name>Butch</Name>
I have a xml file which contains arabic characters.When i try to parse a
maybe this is a n00b-question. I try to parse an xml-file like that: <?xml
I try to parse an xml file. The text which is in tags is
I'm trying to parse an xml file and extract data from it to display
I have a xml file... <?xml version=1.0 ?> -<dict> <ID>USDUSD</ID> <VALUE>0.00</VALUE> <ID>USDGBP</ID> <VALUE>0.6465</VALUE> <ID>USDEUR</ID>

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.