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

  • Home
  • SEARCH
  • 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 5953739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:52:09+00:00 2026-05-22T17:52:09+00:00

I am working with a method using LINQ to XML to return a string.This

  • 0

I am working with a method using LINQ to XML to return a string.This is the XML

       <data name="lnkViewResultResource1.Text" xml:space="preserve">
    <value>View results</value>
  </data>
  <data name="lnkVoteResource1.Text" xml:space="preserve">
    <value>Vote</value>
  </data>
  <data name="number of results" xml:space="preserve">
    <value>You already {0} voted in this poll {1}</value>
  </data>

(I want to take the “name” attribute)
This is my method:

    Public Shared Function getlabel(ByVal filename As String, ByVal valuetrans As String) As String
    Dim label = From l In XElement.Load(filename).Elements("data") Where l.Element("value").Value = valuetrans Select (l.Attribute("name").Value).First
    Return label.ToString
End Function

And this is returning this :

System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String]

I googled and used following this link FirstOrDefault(), but it didn’t work in my case.
Any ideas?

Thanks in advance,

Alf.

  • 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-22T17:52:09+00:00Added an answer on May 22, 2026 at 5:52 pm

    I think your call to ‘First’ is placed wrong, try this:

    Dim query = From l In XElement.Load(filename).Elements("data") _ 
         Where l.Element("value").Value = valuetrans _
         Select (l.Attribute("name").Value)
    Dim label = query.First()
    Return label.ToString()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, My goal: To validate an XML document then load the data into a
I am using visual studio 2010, (desktop application) and using LINQ to SQL to
I am using a book to study, and am stuck here If you have
I'm working on a library that allows users to input arbitrary expressions. My library
What I'm trying to do is allow a user to write a method in
Im very new to the WPF and MVVM (this is my 1st project in
I'm using RIA services with Silverlight 4 and would like to limit the fields
I'm working on a C# application that allows users to basically import tables of
Hello everybody With EF4, i can map a EDMX function (with update model from
I am new to WCF and I'm also learning the MVP design pattern. I

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.