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

The Archive Base Latest Questions

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

var query = from k in xDoc.Descendants(product) select new { KategoriKod =Convert.ToString( k.Element(cat1).Value) +

  • 0
var query = from k in xDoc.Descendants("product")
                               select
                                new
                                {

                                 KategoriKod =Convert.ToString( k.Element("cat1").Value) + Convert.ToString( k.Element("cat2").Value),

                                };

I want to take two elemens of an xml file by one variable. but I recieve this Error

“‘string’ does not contain a definition for ‘Value’ ”

any one help plz.?

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

    The following works for me:

    static void Main(string[] args)
    {
        var xDoc = XDocument.Parse(
    @"<root>
        <product>
            <cat1>ABC</cat1>
            <cat2>123</cat2>
        </product>
        <product>
            <cat1>XYZ</cat1>
        </product>
    </root>");
    
        var query = from k in xDoc.Descendants("product")
                    select new 
                    {
                        KategoriKod = (string)k.Element("cat1") + (string)k.Element("cat2")
                    };
    
        foreach(var k in query)
        {
            Console.WriteLine(k);
        }
    }
    

    Here is the result:

    { KategoriKod = ABC123 }
    { KategoriKod = XYZ }
    Press any key to continue . . .

    Note that I used explicit conversion operator (casting elements to string) to avoid NullReferenceExceptions in when calling .Value on elements that do not exist.

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

Sidebar

Related Questions

I want to use this query: var queryData = from va in xdoc.Descendants(language) select
var query = from p1 in Enumerable.Range(2,3) from p2 in Enumerable.Range(4,5) select new {
public static void MyFunction(MyErrorClass err) { var query = from filter in DataContext.ErrorFilters select
var query = from d in testPersons.person where d.Name == txtbox select d; txtbox
My simple one keyword query works as follows: var query = from product in
public static IList<string> GetAttribute_1(ModelContainer context, long productcatid) { var query = from product in
Consider this code: var query = from groupRole in CurrentItem.MEMGroupRoles select groupRole.MEMRole; this.AvailableRoles =
var query = from c in db.Customers select c; query = query.Where(c => c.Orders.Where(o
For example: var query = from c in db.Cars select c; foreach(Car aCar in
Suppose following codes: IEnumerable<MyClass> MakeQuery() { var query = from m in session.Linq<MyClass>() select

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.