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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:10:44+00:00 2026-06-11T04:10:44+00:00

consider this HTML: <table> <tr> <td width=45% align=right> <h2>1.00 NZD</h2> </td> <td valign=top align=center>

  • 0

consider this HTML:

<table>
  <tr>
    <td width="45%" align="right">
      <h2>1.00 NZD</h2>
    </td> 
    <td valign="top" align="center">
      <h2>=</h2>
    </td> 
    <td width="45%" align="left">
      <h2>0.415528 GBP</h2>
    </td>
  </tr>
</table>

I use this code as string and convert it to a XML file:

string raw = "<table><tr><td width=\"45%\" align=\"right\"><h2>1.00 NZD</h2></td><td valign=\"top\" align=\"center\"><h2>=</h2></td><td width=\"45%\" align=\"left\"> <h2>0.415528 GBP</h2> </td></tr></table>";

XElement info = XElement.Parse(raw);

now I want to get All td that have align="right" and write this code:

var elementToChange = (from c in info.Elements("td")
                            where c.Attribute("align").Value == "right"
                            select c);


 Label1.Text = Server.HtmlEncode(elementToChange.First().ToString());

but I get this Error:

Sequence contains no elements

where is problem?

thanks

  • 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-11T04:10:45+00:00Added an answer on June 11, 2026 at 4:10 am

    You look for "td" elements but at the top level of the node you only find a "tr" element. That’s why you don’t get any elements. Try this:

    from c in info.Elements("tr").Elements("td")
    

    Also, you should check if there are any elements in the sequence before calling First() (or use FirstOrDefault() which returns null if there is no element).

    If you don’t know the path and only want all "td" elements with that tag value, you can also use the Descendants extension method:

    from c in info.Descendants("td")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem is only in IE. Consider the following HTML: <html> <body> <div style='position:absolute;left:1em;right:1em;top:1em;bottom:1em;overflow:auto;>
Consider this HTML: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd> <html xmlns=http://www.w3.org/1999/xhtml> <table cellspacing
Consider this code : HTML: <table> <tr> <td>Option 1</td> <td><input type='checkbox' id='option1' /></td> </tr>
Question: I'm having a little trouble with jQuery: Consider this HTML, where I want
Consider this page @ http://www.bloodbone.ws/screwed.html I need to be able to have the a.grow
I'm parsing JSON that is contained in an HTML element. Consider this markup: <div
Consider the following HTML string: <p>This is line 1 <br /> and this is
Consider this simple model: A base Location table: +-------------------------------+ | Locations | +-------------------------------+ |(PK)
Please consider the following HTML: <td> Some Text <table>.....</table> </td> I need to manipulate
Consider simple XML document: <html><body> <table> <tr><td> Item 1</td></tr> <tr><td> Item 2</td></tr> </table> </body></html>

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.