, Guest>> || || |
/ Microsoft SQL Server
 xQuery  [new]
Nemoxur
Member

:
: 176
, .
, ,

SET LANGUAGE 'Russian';
DECLARE @xml XML = 
'
<>
  < ="25.02.2016" ="2015">
     < ="13">
      <>
        < ="01" ="2000" ="345.63" />
        < ="01" ="4800" ="371.00" />
        < ="02" ="2000" ="237.78" />
        < ="02" ="2012" ="172.72" />
      </>
    </>
    < ="35">
      <>
        < ="01" ="2610" ="116.77" />
        < ="02" ="2610" ="87.89" />
        < ="03" ="2610" ="77.84" />
      </>
    </>
   </>
</>
'
SELECT [color=red][/color]
	[]	= doc.col.value('@', 'date')
,	[]	= doc.col.value('@', 'int')
,	[] = doc.col.value('[1]/@','int')
,	[] = x.col.value('@', 'varchar(2)')
,	[] = x.col.value('@', 'int')
,	[] = x.col.value('@', 'decimal(19,2)')
FROM @xml.nodes('//') AS doc(col)
CROSS APPLY doc.col.nodes( '//' ) AS x (col)


35, 13 .

2016-02-25 2015 13 01 2000 345.63
2016-02-25 2015 13 01 4800 371.00
2016-02-25 2015 13 02 2000 237.78
2016-02-25 2015 13 02 2012 172.72
2016-02-25 2015 35 01 2610 116.77
2016-02-25 2015 35 02 2610 87.89
2016-02-25 2015 35 03 2610 77.84
28 19, 10:14[21821428]      |
 Re: xQuery  [new]
invm
Member

:
: 9344
[] = x.col.value('(../..)[1]/@','int')
28 19, 10:23[21821438]      |
 Re: xQuery  [new]
Nemoxur
Member

:
: 176
invm,

!
28 19, 10:34[21821449]      |
 Re: xQuery  [new]
Nemoxur
Member

:
: 176
+
DECLARE @xml xml= '< ="NO_NDFL0_0000_0000_0000000000000000000_00000000_0000d0fd-000c-0fbf-0000-f00ffd0000d0" ="-  0.0" ="0.00">

  < ="00000000" ="0000" ="0">

    < ="0000000000" ="000000000" />

    < ="0">
      < ="" ="" ="" />

      < =" 000  00.00.0000" ="test" />

    </>

  </>

< ="0000000" ="0000" ="00" ="0" ="00.00.0000" ="0000" ="0000">

    < ="00000000">

      < ="test" ="000000000" ="000000000" />

    </>

    < ="000000000" ="0" ="00.00.0000" ="000">

      < ="" ="" ="" />

      < ="00" ="00 00 00000" />

    </>

    < ="13">

      <>

        < ="00" ="0000" ="000000.00" />

        < ="00" ="0000" ="0000.00" />

        < ="00" ="0000" ="00000.00" />

        < ="00" ="0000" ="0000.00" />

        < ="00" ="0000" ="000000.00" />

        < ="00" ="0000" ="0000.00" />

        < ="00" ="0000" ="000000.00" />

        < ="00" ="0000" ="000000.00" />

        < ="00" ="0000" ="000000.00" />

        < ="00" ="0000" ="0000.00" />

        < ="00" ="0000" ="00000.00" />

        < ="00" ="0000" ="0000.00" />

        < ="00" ="0000" ="00000.00" />

        < ="00" ="0000" ="00000.00" />

        < ="00" ="0000" ="000000.00" />

        < ="00" ="0000" ="0000.00" />

        < ="00" ="0000" ="00000.00" />

        < ="00" ="0000" ="000000.00" />

        < ="00" ="0000" ="0000.00" />

        < ="00" ="0000" ="00000.00" />

        < ="00" ="0000" ="0000.00" />

        < ="00" ="0000" ="0000.00" />

        < ="00" ="0000" ="000000.00" />

        < ="00" ="0000" ="0000.00" />

      </>

      < ="0000000.00" ="0000000.00" ="000000" ="000000" ="000000" ="0" ="0" ="0" />

    </>

    < ="35">

      <>

        < ="00" ="0000" ="000.00" />

        < ="00" ="0000" ="000.00" />

        < ="00" ="0000" ="000.00" />

        < ="00" ="0000" ="000.00" />

        < ="00" ="0000" ="000.00" />

        < ="00" ="0000" ="000.00" />

        < ="00" ="0000" ="000.00" />

        < ="00" ="0000" ="000.00" />

        < ="00" ="0000" ="000.00" />

        < ="00" ="0000" ="000.00" />

        < ="00" ="0000" ="000.00" />

        < ="00" ="0000" ="000.00" />

      </>

      < ="0000.00" ="0000.00" ="0000" ="0000" ="0000" ="0" ="0" ="0" />

    </>

  </>
  < ="0000000" ="0000" ="00" ="0" ="00.00.0000" ="0000" ="0000">
    < ="00000000">
      < ="test" ="0000000000" ="000000000" />
    </>
    < ="000000000000" ="0" ="00.00.0000" ="000">
      < ="" ="" ="" />
      < ="00" ="00 00 000000" />
    </>
    < ="13">
      <>
        < ="00" ="0000" ="00000.00" />
        < ="00" ="0000" ="0000.00" />
      </>
      < ="00000.00" ="00000.00" ="0000" ="0000" ="0000" ="0" ="0" ="0" />
    </>
  </>
  < ="0000000" ="0000" ="00" ="0" ="00.00.0000" ="0000" ="0000">
    < ="00000000">
      < ="test" ="0000000000" ="000000000" />
    </>
    < ="000000000000" ="0" ="00.00.0000" ="000">
      < ="" ="ϸ" ="" />
      < ="00" ="00 00 000000" />
    </>
    < ="13">
      <>
        < ="00" ="0000" ="000.00">
          < ="000" ="000.00" />
        </>
        < ="00" ="0000" ="000.00">
          < ="000" ="000.00" />
        </>
        < ="00" ="0000" ="000.00">
          < ="000" ="000.00" />
        </>
        < ="00" ="0000" ="000.00">
          < ="000" ="000.00" />
        </>
        < ="00" ="0000" ="0000.00">
          < ="000" ="0000.00" />
        </>
        < ="00" ="0000" ="000.00">
          < ="000" ="000.00" />
        </>
      </>
      < ="0000.00" ="000.00" ="00" ="00" ="00" ="0" ="0" ="0" />
    </>
  </>
  < ="0000000" ="0000" ="00" ="0" ="00.00.0000" ="0000" ="0000">
    < ="00000000">
      < ="test" ="0000000000" ="000000000" />
    </>
    < ="000000000000" ="0" ="00.00.0000" ="000">
      < ="" ="" ="" />
      < ="00" ="00 00 000000" />
    </>
    < ="13">
      <>
        < ="00" ="0000" ="00000.00" />
        < ="00" ="0000" ="0000.00" />
        < ="00" ="0000" ="00000.00" />
        < ="00" ="0000" ="0000.00" />
        < ="00" ="0000" ="00000.00" />
        < ="00" ="0000" ="0000.00" />
        < ="00" ="0000" ="00000.00" />
        < ="00" ="0000" ="0000.00" />
        < ="00" ="0000" ="00000.00" />
        < ="00" ="0000" ="0000.00" />
        < ="00" ="0000" ="00000.00" />
        < ="00" ="0000" ="0000.00" />
        < ="00" ="0000" ="00000.00" />
        < ="00" ="0000" ="0000.00" />
      </>
      < ="000000.00" ="000000.00" ="00000" ="00000" ="00000" ="0" ="0" ="0" />
    </>
  </>
  < ="0000000" ="0000" ="00" ="0" ="00.00.0000" ="0000" ="0000">
    < ="00000000">
      < ="test" ="000000000000" ="000000000" />
    </>
    < ="000000000000" ="0" ="00.00.0000" ="000">
      < ="" ="" ="" />
      < ="00" ="00 00 000000" />
    </>
    < ="13">
      <>
        < ="00" ="0000" ="0.00">
          < ="000" ="0.00" />
        </>
        < ="00" ="0000" ="0.00" />
        < ="00" ="0000" ="0.00" />
        < ="00" ="0000" ="0.00" />
        < ="00" ="0000" ="0.00" />
        < ="00" ="0000" ="0.00" />
        < ="00" ="0000" ="0.00" />
        < ="00" ="0000" ="0.00" />
        < ="00" ="0000" ="0.00" />
        < ="00" ="0000" ="0.00" />
        < ="00" ="0000" ="0.00" />
        < ="00" ="0000" ="0.00" />
      </>
      <>
        < ="000" ="0.00" />
        < ="000" ="0.00" />
        < ="000" ="0.00" />
      </>
      < ="0.00" ="0.00" ="0" ="0" ="0" ="0" ="0" ="0" />
    </>
  </>
  </>';

SELECT
	[] = doc.col.value('[1]/[1]/@', 'varchar(100)')
,	[] = doc.col.value('[1]/[1]/@', 'varchar(100)')
,	[] = doc.col.value('[1]/[1]/@', 'varchar(100)')
,	[] = .query('.').value('[1]/@','int')
FROM @xml.nodes('//') AS doc(col)
CROSS APPLY @xml.nodes('///') col()


, , ?

id
1 13
2 35
3 13
4 13
5 13
6 13
7 13
8 35
9 13
10 13
11 13
12 13
13 ϸ 13
14 ϸ 35
15 ϸ 13
16 ϸ 13
17 ϸ 13
18 ϸ 13
19 13
20 35
21 13
22 13
23 13
24 13
25 13
26 35
27 13
28 13
29 13
30 13

: .


: 22 19, 13:16
22 19, 13:10[21931680]      |
 Re: xQuery  [new]
Nemoxur
Member

:
: 176
, .

, .
SELECT	 col.[].value('[1]/[1]/@', 'varchar(100)')
		,col.[].value('[1]/[1]/@', 'varchar(100)')
		,col.[].value('[1]/[1]/@', 'varchar(100)')
		,col2.[].value('@', 'varchar(100)')
FROM @xml.nodes('.') AS doc(col)
CROSS APPLY doc.[col].nodes('/') col()
CROSS APPLY col.[].nodes('') col2()
22 19, 15:53[21931826]      |
/ Microsoft SQL Server