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

The Archive Base Latest Questions

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

I put reading barcode in separate method which reads the barcode and put it

  • 0

I put reading barcode in separate method which reads the barcode and put it in a textbox named barcode. and created a button that will load data coresponding to that barcode , but facing problem

private void Load_Click(object sender, RoutedEventArgs e) 
{
    var str = @"<Books xmlns=""""> <book Barcode=""780672318863""><Serial>11</Serial> 
                           <name>abc</name> <detail>Fantasy</detail></book>
                           <book Barcode=""780672318864""><Serial>12</Serial>
                           <name>abc</name><detail>Fantasy1</detail></book></Books>";
    var strBarcode = barcode.Text;
    MessageBox.Show(strBarCode);
    XDocument docX = XDocument.Parse(str);
    var s = docX.Descendants("book").FirstOrDefault(a => a.Attribute("Barcode").Value == strBarcode);
    spnl.DataContext = s; 
}

now Messagebox says strBarCode has correct value but it is not showing up in program and
s value is coming out to be null
on other hand if i put directly “780672318863” in place of strBarcode it is showing value correctly
can anyone tell me where i am going wrong ?

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

    Not reproducable.

    I ran your code with docX.Descendants("book")... and it produces the correct element.

    You could try

      string  strBarcode = barcode.Text.Trim();
    

    but for the rest you will just have to look around in the debugger.

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

Sidebar

Related Questions

Put them all in one separate folder structure or along with classes which implements
I have a System.Web.UI.Page page which receive both POST and PUT HTTP requests. Reading
I have a camera object that I have put together from reading on the
I have a long method, and for reading clarity would like to put some
From reading PEP-8, I get it that you should put the closing parenthesis on
can you use Insert Iterators while reading from a file to put the data
Put it another way: what code have you written that cannot fail. I'm interested
We put all of our unit tests in their own projects. We find that
To put it simple, there's a simple java swing app that consists of JFrame
I am using a progress bar in android, so that till my data is

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.