oracle查询使用oracle获取xml节点及其值的列表

时间:2017-08-29 18:43:58

标签: oracle

我有一个XML列,我需要帮助来编写查询以显示节点及其值。

下面是我的xml列中的数据:

<item_content>
  <stimulus_reference>
    <table_wrapper>
      <table frame="all" colsep="1" rowsep="1" pgwide="0">
        <tgroup cols="3">
          <thead>
            <row>
              <entry />
              <entry align="center">Male</entry>
              <entry align="center">Female</entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry align="left">Juniors</entry>
              <entry align="right">12</entry>
              <entry align="right">3</entry>
            </row>
            <row>
              <entry align="left">Seniors</entry>
              <entry align="right">9</entry>
              <entry align="right">21</entry>
            </row>
          </tbody>
        </tgroup>
      </table>
    </table_wrapper>
    <rationale>This is a rationale paragraph</rationale>
  </stimulus_reference>
  <task>
    <item_stem>
      <stem_paragraph>The table above shows the distribution of students that attended a concert, by class and gender.</stem_paragraph>
    </item_stem>
    <item_response>
      <response_choices>
        <columnar_choice_list>
          <columns align="character" align_character="1">
            <choice_row numeric_identifier="1">
              CHROW1
              <choice_cell>3</choice_cell>
            </choice_row>
            <choice_row numeric_identifier="2">
              CHROW2
              <choice_cell>15</choice_cell>
            </choice_row>
            <choice_row numeric_identifier="3">
              CHROW3
              <choice_cell>2102</choice_cell>
            </choice_row>
            <choice_row numeric_identifier="4">
              CHROW4
              <choice_cell>321</choice_cell>
            </choice_row>
            ColumnsData
          </columns>
        </columnar_choice_list>
      </response_choices>
    </item_response>
  </task>
  <math_expression>1+2=3</math_expression>
</item_content>

我希望以下格式输出

Node_Name               Node_val

stimulus_reference
table_wrapper
table
tgroup
thead
row
entry
entry                   Male
entry                   Female
tbody
row
entry                   Juniors
entry                   12
entry                   3
row
entry                   Seniors 
entry                   9
entry                   21
task
item_stem
stem_paragraph              The table above shows the distribution of students that attended a concert, by class and gender. 
item_response
response_choices
columnar_choice_list
columns                 ColumnsData
choice_row              CHROW1
choice_cell             3
choice_row              CHROW2
choice_cell             15
choice_row              CHROW3
choice_cell             2102
choice_row              CHROW4
choice_cell             321

感谢您对此的帮助。

1 个答案:

答案 0 :(得分:1)

public Image byteArrayToImage(byte[] byteArrayIn) { MemoryStream ms = new MemoryStream(byteArrayIn); Image returnImage = Image.FromStream(ms); return returnImage; } public bool ByteArrayToFile(string _FileName, byte[] _ByteArray) { try { System.IO.FileStream _FileStream = new System.IO.FileStream(_FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write); _FileStream.Write(_ByteArray, 0, _ByteArray.Length); _FileStream.Close(); return true; } catch (Exception _Exception) { Console.WriteLine("Exception caught in process: {0}", _Exception.ToString()); } return false; } 返回所有级别的所有节点 //*返回节点名称
name()返回节点值

如果您只想要文本节点,则必须将text()替换为//*

//*[text()]