mardi 5 mai 2015

Capturing mutliple XML strings with the same node names in SQL

Weaving my way through the XML string world - I've come across this issue I'm having.

So I have two XML string that are super similar to each other - only thing is - is that they have different info inside the nodes.

XML string 1:

<DocumentElement>
 <Readings>
  <ReadingID>1</ReadingID>
  <ReadingDate>2013-12-19T00:00:00-05:00</ReadingDate>
  <Sys>120</Sys>
  <Dia>80</Dia>
  <PageNumber>4</PageNumber>
  <AddedDate>2015-04-17T19:30:22.2255116-04:00</AddedDate>
  <UpdateDate>2015-04-17T19:30:22.2255116-04:00</UpdateDate>
 </Readings>
 <Readings>
  <ReadingID>2</ReadingID>
  <ReadingDate>2014-01-10T00:00:00-05:00</ReadingDate>
  <Sys>108</Sys>
  <Dia>86</Dia>
  <PageNumber>8</PageNumber>
  <AddedDate>2015-04-17T19:32:08.5121747-04:00</AddedDate>
  <UpdateDate>2015-04-17T19:32:08.5121747-04:00</UpdateDate>
 </Readings>
</DocumentElement>

XML String 2:

<DocumentElement>
 <Readings>
  <ReadingID>1</ReadingID>
  <ReadingDate>2013-12-20T00:00:00-05:00</ReadingDate>
  <Sys>140</Sys>
  <Dia>70</Dia>
  <PageNumber>10</PageNumber>
  <AddedDate>2015-04-17T19:30:22.2255116-04:00</AddedDate>
  <UpdateDate>2015-04-17T19:30:22.2255116-04:00</UpdateDate>
 </Readings>
</DocumentElement>

Now this is really just an example - I could have an infinite amount of strings just like this that I would want to pull data from. In this case I have two strings and I'm looking to extract all info on <Sys>, <Dia> and <ReadingDate>

I would also like to display this info in a table like this:

Reading Date |  Sys  | Dia
----------------------------
12/29/2013   |  120  | 80
----------------------------
1/10/2014    |  108  | 86
----------------------------
12/20/2013   |  140  | 70

I am totally unsure how to proceed with this - any and all help is appreciated!

Aucun commentaire:

Enregistrer un commentaire