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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:14:22+00:00 2026-06-03T18:14:22+00:00

I want to get all the Reading nodes and their values from each session

  • 0

I want to get all the Reading nodes and their values from each session in my xml document as well as obtaining the session ID from the parent node. I am running this on a SQL Server 2008 instance.

My xml setup is:

<Sessions>
<SessionID>99</SessionID>
<Readings>
  <Reading>
    <Point>
      <Lat>-40.411558</Lat>
      <Lng>175.63504</Lng>
    </Point>
    <Heading>54</Heading>
    <Speed>0.1</Speed>
    <Height>0</Height>
    <FlowRate>0.69</FlowRate>
    <AppRate>74</AppRate>
  </Reading>
  ... more readings
</Readings>
<Sessions>

My original attempt (which works) was shown below however this seems extremely slow when I run it. However when I take out the line that add’s the SessionID i.e ../../SessionID it seems to perform much faster. It takes a 12sec query down to just 2sec.

        SELECT
            [SessionID] = c.value('(../../SessionID)[1]', 'int'),
            [Heading] = c.value('(Heading)[1]', 'float'),
            [Speed] = c.value('(Speed)[1]', 'float'),
            [Height] = c.value('(Height)[1]', 'float'),
            [FlowRate] = c.value('(FlowRate)[1]', 'float'),
            [AppRate] = c.value('(AppRate)[1]', 'float'),
            [Latitude] = c.value('(Point/Lat)[1]', 'float'),
            [Longtitude] = c.value('(Point/Lng)[1]', 'float')
        FROM
            @XMLData.nodes('/Sessions/Readings/Reading') XMLData(c)

Is there anyway I can do this without the need to reference SessionID using the ../../ notation. I do need the SessionID as this query is being used to insert records into a temporary table:

insert into #MyTempTable
SELECT
            [SessionID] = c.value('(../../SessionID)[1]', 'int'),
            [Heading] = c.value('(Heading)[1]', 'float'),
            [Speed] = c.value('(Speed)[1]', 'float'),
            [Height] = c.value('(Height)[1]', 'float'),
            [FlowRate] = c.value('(FlowRate)[1]', 'float'),
            [AppRate] = c.value('(AppRate)[1]', 'float'),
            [Latitude] = c.value('(Point/Lat)[1]', 'float'),
            [Longtitude] = c.value('(Point/Lng)[1]', 'float')
        FROM
            @XMLData.nodes('/Sessions/Readings/Reading') XMLData(c)
  • 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-03T18:14:31+00:00Added an answer on June 3, 2026 at 6:14 pm

    For the first part of avoiding ../../ you can use CROSS APPLY to to provide both data sets.

    Also if you would like a faster INSERT and are not worried about logging, the SELECT INTO statement would provide a much faster insert:

    SELECT
        s.value('(SessionID)[1]', 'int') SessionID,             
        r.value('(Heading)[1]', 'float') Heading,
        r.value('(Speed)[1]', 'float') Speed,
        r.value('(Height)[1]', 'float') Height,
        r.value('(FlowRate)[1]', 'float') FlowRate,
        r.value('(AppRate)[1]', 'float') AppRate,
        r.value('(Point/Lat)[1]', 'float') Latitude,
        r.value('(Point/Lng)[1]', 'float') Longtitude
    INTO #Reading
    FROM
        @XMLData.nodes('/Sessions') as S(s)
        CROSS APPLY 
        s.nodes('./Readings/Reading') XMLData(r)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get all values of a set interface in one go as
I want to get all values of 'id' attribute of 'span' tag with html
I want to get all the records from the one table which contain at
I want to get all conflict documents from a Notes database. So far, i've
How do I get all the TITLE and LINKS reading from a file ?
I'm having a little trouble reading the values of all the sub child nodes
I want get all of the Geom objects that are related to a certain
I want to get all the error messages out of the modelState without knowing
I want to get all anchor elements on my page where the attribute rel
i want to get all the details of youtube,so if the user tick 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.