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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:51:14+00:00 2026-06-12T18:51:14+00:00

I am using XML.Linq to search through an XML file. <Location id=1284 parentID=1333 level=4

  • 0

I am using XML.Linq to search through an XML file.

    <Location id="1284" parentID="1333" level="4" writerID="0" creatorID="3" nodeType="1266" template="1272" sortOrder="0" createDate="2012-04-09T09:41:33" updateDate="2012-08-16T11:43:11" nodeName="Princeton Junction" urlName="princeton-junction" writerName="Web" creatorName="My Name" path="-1,1092,1258,1333,1284" isDoc="">
      <solutionsOfferedIndustries>1109,1172,1290,1293,1295,1296,1298,1300,1302</solutionsOfferedIndustries>
      <umbracoUrlAlias>
      </umbracoUrlAlias>
      <uHidesy><![CDATA[{"document":{"id":1284,"documentType":"Location","tabs":[{"name":"Address & Contact Info","index":0,"properties":[{"name":"Map Position\u003cbr\u003e","index":0,"status":"show"},{"name":"Location Name","index":0,"status":"hide"},{"name":"Office Type\u003cbr\u003e","index":0,"status":"show"},{"name":"State (if in USA)","index":0,"status":"show"},{"name":"Street Address\u003cbr\u003e","index":0,"status":"show"},{"name":"Street Address (Line 2)","index":0,"status":"show"},{"name":"City\u003cbr\u003e","index":0,"status":"show"},{"name":"ZIP Code/Postal Code\u003cbr\u003e","index":0,"status":"show"},{"name":"Country","index":0,"status":"show"},{"name":"Location Phone Number","index":0,"status":"show"},{"name":"Location Fax Number","index":0,"status":"show"}],"status":"show"},{"name":"Building Photo","index":1,"properties":[{"name":"Upload Image\u003cbr\u003e","index":1,"status":"show"},{"name":"-Property-name-not-displayed-","index":1,"status":"show"}],"status":"show"},{"name":"Solutions Offered","index":2,"properties":[{"name":"Solutions Offered - Industries","index":2,"status":"show"}],"status":"show"},{"name":"Miscellaneous","index":3,"properties":[{"name":"Custom Page URL\u003cbr\u003e","index":3,"status":"hide"},{"name":"Divisions\u003cbr\u003e","index":3,"status":"show"},{"name":"General Manager","index":3,"status":"show"},{"name":"Notes\u003cbr\u003e","index":3,"status":"hide"}],"status":"show"},{"name":"Tab & Property Visibility","index":4,"properties":[{"name":"uHidesy\u003cbr\u003e","index":4,"status":"show"}],"status":"hide"},{"name":"Properties","index":5,"properties":[{"name":"Name","index":5,"status":"hide"},{"name":"Created by","index":5,"status":"hide"},{"name":"Created","index":5,"status":"hide"},{"name":"Id","index":5,"status":"hide"},{"name":"Document Type","index":5,"status":"hide"},{"name":"Template","index":5,"status":"hide"},{"name":"Publication Status","index":5,"status":"hide"},{"name":"Last edited","index":5,"status":"hide"},{"name":"Publish at","index":5,"status":"hide"},{"name":"Remove at","index":5,"status":"hide"},{"name":"Link to document","index":5,"status":"show"}],"status":"show"}],"applyToAll":true,"applyToAdmin":false,"savedDate":"16/08/2012 15:01:35"}}]]></uHidesy>
      <umbracoFile>/media/5153/front_of_building.jpg</umbracoFile>
      <coordinates><![CDATA[40.297833,-74.64424600000001,13]]></coordinates>
      <imageCrop>
        <crops date="10/05/2012 10:33:52">
          <crop name="Location Photo" x="287" y="0" x2="1785" y2="1498" url="/media/5153/front_of_building_Location Photo.jpg" />
        </crops>
      </imageCrop>
      <locationName>Princeton Junction</locationName>
      <officeType>Corporate Headquarters</officeType>
      <state><![CDATA[NJ - New Jersey]]></state>
      <streetAddress>123 My Road</streetAddress>
      <streetAddress2>
      </streetAddress2>
      <city>Princeton Junction</city>
      <zipCode>08550</zipCode>
      <country>United States</country>
      <divisions><![CDATA[Services,Products & Systems]]></divisions>
      <locationPhoneNumber>123-456-7890</locationPhoneNumber>
      <locationFaxNumber>123-456-7891</locationFaxNumber>
      <generalManager>
      </generalManager>
      <notes><![CDATA[Blah:
          -Blah1
          -Blah2
          -Blah3]]></notes>
    </Location>

I am using the following code to get everything I need but I also need to get the attribute url of Location\imageCrop\crops\crop.

    var query = from c in xmldoc.Root.Descendants("Location")
                    select c.Attribute("id").ToString().Replace("\"", "").Replace("id=", "") + "\t"
                            + c.Element("locationName").Value + "\t"
                            + c.Element("streetAddress").Value + "\t"
                            + c.Element("streetAddress2").Value + "\t"
                            + c.Element("city").Value + "\t"
                            + c.Element("state").Value + "\t"
                            + c.Element("zipCode").Value + "\t"
                            + c.Element("country").Value + "\t"
                            + c.Element("locationPhoneNumber").Value + "\t"
                            + c.Element("locationFaxNumber").Value+ "\t"
                            + c.Attribute("urlName").ToString().Replace("\"", "").Replace("urlName=", "");

How do I add that subquery to this query?

  • 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-12T18:51:15+00:00Added an answer on June 12, 2026 at 6:51 pm

    You just need:

    c.Element("imageCrop").Element("crops").Element("crop").Attribute("url").Value
    

    Of course, if there are multiple crop attributes, that will only return the first one – is that okay for you?

    (As an aside, I would personally transform to an anonymous type with all the values stored in separate properties, and then convert that to a tab-separated value as a next step; I think you’d find it would make debugging easier.)

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

Sidebar

Related Questions

When reading a XML file with linq to XML using a XDocument and there
I am trying to learn how to search XML trees with LINQ using VB.net.
I am trying to extract values from an XML file using linq to create
I am having troubles finding elements in an Xml file using LINQ to XML
i am using linq-to-xml to search elements. var doc = XDocument.Load(reader); var ns =
How to write binary data into XML using LINQ which is being read from
using LINQ to XML, this is a sample of my XML <shows> <Show Code=456
I am using Linq to XML for some HTML output files. I need to
I'm using Linq-to-XML to do a simple is this user registered check (no security
I'm trying to find the inner text value of an element using LINQ-to-XML (an

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.