Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Extract table from XML variable

$
0
0

I have the following XML and want to extract the data into a table in the format below. Can someone help please

StopId   PassID

1           1

2           2

3           1

4           2

XML

<OrderDetail>

<Passengers>

<Passenger>

      <PassID>1</PassID>

      <PassFName>Bob</PassFName>

      <PassengerStops>

        <PassengerStop>

          <StopId>1</StopId>

          <StopPurpose>P</StopPurpose>

        </PassengerStop>

        <PassengerStop>

          <StopId>3</StopId>

          <StopPurpose>D</StopPurpose>        

        </PassengerStop>

      </PassengerStops>

    </Passenger>

    <Passenger>

      <PassID>2</PassID>

      <PassFName>Jim</PassFName>

      <PassengerStops>

        <PassengerStop>

          <StopId>2</StopId>

          <StopPurpose>P</StopPurpose>

        </PassengerStop>

        <PassengerStop>

          <StopId>4</StopId>

          <StopPurpose>D</StopPurpose>

        </PassengerStop>

      </PassengerStops>

    </Passenger>

  </Passengers>

</OrderDetail>


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>