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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:06:34+00:00 2026-05-16T10:06:34+00:00

I need to write a Linq query to get XElements based on Attribute Name.

  • 0

I need to write a Linq query to get XElements based on Attribute Name.

The XMl is not a structured one.. The attribute may there at the top of some XML node or any where in the xml ?

Well actually it is the word document the xml file document.xml there will be places it uses the r:Id ,Now i need to get all the Elements which contain this attribute !

Below is the XML

> <w:p w:rsidR="00302209"
> w:rsidRDefault="005C326E"
> w:rsidP="00302209">
> - <w:pPr>   <w:framePr w:w="3186" w:h="1701" w:hSpace="142"
> w:wrap="around" w:vAnchor="page"
> w:hAnchor="page" w:x="8688"
> w:y="11449" />    <w:spacing
> w:line="240" w:lineRule="exact" /> 
> - <w:rPr>   <w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"
> />    <w:szCs w:val="24" />   
> </w:rPr>   </w:pPr>
> - <w:hyperlink r:id="rId6" w:history="1">
> - <w:r w:rsidR="00302209">
> - <w:rPr>   <w:rStyle w:val="Hyperlink" />    <w:rFonts
> w:ascii="Times New Roman"
> w:hAnsi="Times New Roman" />   
> <w:szCs w:val="24" />    </w:rPr>  
> <w:t>dd.com</w:t>    </w:r>  
> </w:hyperlink>   </w:p> <w:sectPr
> w:rsidR="001D3CA8"
> w:rsidRPr="00E275EA"
> w:rsidSect="00522450">  
> <w:headerReference w:type="even"
> r:id="rId7" />    <w:headerReference
> w:type="default" r:id="rId8" />   
> <w:footerReference w:type="even"
> r:id="rId9" />    <w:footerReference
> w:type="default" r:id="rId10" />   
> <w:headerReference w:type="first"
> r:id="rId11" />    <w:footerReference
> w:type="first" r:id="rId12" />   
> <w:pgSz w:w="11907" w:h="16840"
> w:code="9" />    <w:pgMar w:top="1701"
> w:right="3572" w:bottom="510"
> w:left="1134" w:header="567"
> w:footer="238" w:gutter="0" />   
> <w:cols w:space="708" />    <w:titlePg
> />    </w:sectPr>

Regards
Francis P.

  • 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-16T10:06:34+00:00Added an answer on May 16, 2026 at 10:06 am

    Sure, it’s easy:

    var elements = doc.Descendants().Where(x => x.Attribute("Foo") != null);
    

    Let me know if that’s not what you were after…

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

Sidebar

Related Questions

I need to write linq to xml query of such kind of below xml
I'm trying to write Linq query on this Products table based on FacetTypes that
I'm trying to write the following LINQ-Entities query: Get a list of Questions, that
I need to write the following SQL statement in LINQ lambdas : SELECT *
I need to write a query where I need to find the ' character.
I'm trying to write a linq-to-sql query using || that behaves the same way
Is there a way to create LINQ query that will have different grouping fields.
I'm attempting to write a linq query which uses several tables of related data
I am a newbie to Linq. I am trying to write a linq query
I need to compare two DateTime properties in a linq query, similar to the

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.