Flatten the recursive XML tree

Hello

I'm trying to parse some XML and flatten for further processing. Using a variation on the code in this post [url http://forums.oracle.com/forums/thread.jspa?threadID=2210708 & tstart = 0] (thanks odie_63!) I can get insofar as:
CREATE TABLE xml_test OF XMLType;

INSERT INTO xml_test
VALUES(XMLType('<Node>Text<Condition>CondType1<From>XX</From>
    <To>YY</To>
  </Condition>
  <Node>Child1<Condition>CondType2<Type>0</Type>
      <Number>12,34,56,89,0012</Number>
    </Condition>
    <Node>Child2<Condition>CondType3<From>Mon</From>
        <To>Fri</To>
      </Condition>
      <Tariff>Fee<Price>50</Price></Tariff>
      <Tariff>Rate<Price>10</Price><Interval>60</Interval></Tariff>
    </Node>
    <Node>DefaultRate<Tariff>Fee<Price>5000</Price></Tariff></Node>
  </Node>
</Node>'));

COMMIT;

SELECT x.*
FROM xml_test xt,
     XMLTable(
     'declare function local:getID($e as node()) as xs:integer
      {
       for $i at $j in $d/descendant::*
       where $i is $e
       return $j
      }
      ; declare function local:getConditions($c as node()) as element()*
      {
       for $cond in $c/child::Condition
       return element r
       {
        element condtype1_from { if ($cond/text() = "CondType1") then $cond/From/text() else () },
        element condtype1_to {if ($cond/text() = "CondType1") then $cond/To/text() else ()},
        element condtype2_type { if ($cond/text() = "CondType2") then $cond/Type/text() else () },
        element condtype2_number {if ($cond/text() = "CondType2") then $cond/Number/text() else ()},
        element condtype3_from { if ($cond/text() = "CondType3") then $cond/From/text() else () },
        element condtype3_to {if ($cond/text() = "CondType3") then $cond/To/text() else ()}
       }
      }; declare function local:getTariff($tariff as node()) as element()*
      {
       for $t in $tariff/child::Tariff
       return element r
       {
         element fee_price {if ($t/text() = "Fee") then $t/Price/text() else ()},
         element rate_price {if ($t/text() = "Rate") then $t/Price/text() else ()},
         element rate_interval {if ($t/text() = "Rate") then $t/Interval/text() else ()}
       }
      }; declare function local:getChildren($e as node(), $pID as xs:integer?) as element()*
      {
       for $i in $e/child::Node
       let $ID := local:getID($i)
       let $c := local:getConditions($i)
       let $t := local:getTariff($i)
       return element r
       {
        element tag_id {$ID},
        element parent_tag_id {$pID},
        element tag_name {local-name($i)},
        element tag_text {$i/text()},
        element attr_list {string-join(for $j in $i/@* return concat(local-name($j),''="'',$j,''"'')," ")},
        element condtype1_from { $c/condtype1_from },
        element condtype1_to { $c/condtype1_to },
        element condtype2_type { $c/condtype2_type },
        element condtype2_number { $c/condtype2_number },
        element condtype3_from { $c/condtype3_from },
        element condtype3_to { $c/condtype3_to },
        element fee_price { $t/fee_price },
        element rate_price { $t/rate_price },
        element rate_interval { $t/rate_interval }
       }
        | local:getChildren($i,$ID)
      }; local:getChildren($d,())'
      passing xt.object_value as "d"
      columns tag_id        number        path 'tag_id',
              parent_tag_id number        path 'parent_tag_id',
              tag_name      varchar2(50)  path 'tag_name',
              tag_text      VARCHAR2(50)  path 'tag_text',
              attr_list     varchar2(4000) path 'attr_list',
              condtype1_from varchar2(100) path 'condtype1_from',
              condtype1_to varchar2(100) path 'condtype1_to',
              condtype2_type varchar2(100) path 'condtype2_type',
              condtype2_number varchar2(100) path 'condtype2_number',
              condtype3_from varchar2(100) path 'condtype3_from',
              condtype3_to varchar2(100) path 'condtype3_to',
              fee_price number path 'fee_price',
              rate_price number path 'rate_price',
              rate_interval number path 'rate_interval'
     ) x;
Gives me
TAG_ID                 PARENT_TAG_ID          TAG_NAME   TAG_TEXT     CONDTYPE1_FROM CONDTYPE1_TO CONDTYPE2_TYPE         CONDTYPE2_NUMBER     CONDTYPE3_FROM CONDTYPE3_TO FEE_PRICE              RATE_PRICE             RATE_INTERVAL          
---------------------- ---------------------- ---------- ------------ -------------- ------------ ---------------------- -------------------- -------------- ------------ ---------------------- ---------------------- ---------------------- 
1                                             Node       Text         XX             YY                                                                                                                                                        
5                      1                      Node       Child1                                   0                      12,34,56,89,0012                                                                                                      
9                      5                      Node       Child2                                                                               Mon            Fri          50                     10                     60                     
18                     5                      Node       DefaultRate                                                                                                      5000                                                                 
I don't see how reach (whether via XML or SQL right - recursion or same PL/SQL) is how to flatten slightly further given the rules:
< li > three types of node is node, Condition and price.
< li > node A is always the starting point and can have zero, one or several Conditions and may have more than one node at the same level.
< li > after the crossing of all nodes and Conditions will end one or two nodes in tariff.
< li > I want to consolidate the conditions where they appear at different levels for a fee (to be delimited by a character, for example a 'C').
< li > the "tag_text" should come together to form the unique path to the tariff.
< li > A node that ends in a tariff grid is not all child nodes more of any type.

The output I want aim (above) would be:
TAG_ID                 PARENT_TAG_ID          TAG_NAME   TAG_TEXT                  CONDTYPE1_FROM CONDTYPE1_TO CONDTYPE2_TYPE         CONDTYPE2_NUMBER     CONDTYPE3_FROM CONDTYPE3_TO FEE_PRICE              RATE_PRICE             RATE_INTERVAL
---------------------- ---------------------- ---------- ------------------------- -------------- ------------ ---------------------- -------------------- -------------- ------------ ---------------------- ---------------------- ---------------------- 
1                                             Node       /Text/Child1/Child2       XX             YY           0                      12,34,56,89,0012     Mon            Fri          50                     10                     60
18                                            Node       /Text/Child1/DefaultRate  XX             YY           0                      12,34,56,89,0012                                 5000
I would really, really appreciate any input on this one because I think I looked at it for far too long... I'm almost there still can not quite end the.

Thank you very much

Gareth.

Hi Gareth,

  • I want to consolidate the conditions where they appear at different levels for a fee (to be delimited by a character, for example a 'C').

  • Could you give an example? It shall apply on the sample?

    Additional question:
    On the final output, you still need TAG_ID, PARENT_TAG_ID and TAG_NAME?

    If I understand what you're after, a quick way is to use a CONNECT BY clause directly on your existing query:

    SELECT sys_connect_by_path(x.tag_text, '/') as tag_text
         , sys_connect_by_path(x.condtype1_from, '/') as condtype1_from
         , sys_connect_by_path(x.condtype1_to, '/') as condtype1_to
         , sys_connect_by_path(x.condtype2_type, '/') as condtype2_type
         , sys_connect_by_path(x.condtype2_number, '/') as condtype2_number
         , sys_connect_by_path(x.condtype3_from, '/') as condtype3_from
         , sys_connect_by_path(x.condtype3_to, '/') as condtype3_to
         , x.fee_price
         , x.rate_price
         , x.rate_interval
    FROM xml_test xt,
         XMLTable(
         'declare function local:getID($e as node()) as xs:integer
          {
           for $i at $j in $d/descendant::*
           where $i is $e
           return $j
          }
          ; declare function local:getConditions($c as node()) as element()*
          {
           for $cond in $c/child::Condition
           return element r
           {
            element condtype1_from { if ($cond/text() = "CondType1") then $cond/From/text() else () },
            element condtype1_to {if ($cond/text() = "CondType1") then $cond/To/text() else ()},
            element condtype2_type { if ($cond/text() = "CondType2") then $cond/Type/text() else () },
            element condtype2_number {if ($cond/text() = "CondType2") then $cond/Number/text() else ()},
            element condtype3_from { if ($cond/text() = "CondType3") then $cond/From/text() else () },
            element condtype3_to {if ($cond/text() = "CondType3") then $cond/To/text() else ()}
           }
          }; declare function local:getTariff($tariff as node()) as element()*
          {
           for $t in $tariff/child::Tariff
           return element r
           {
             element fee_price {if ($t/text() = "Fee") then $t/Price/text() else ()},
             element rate_price {if ($t/text() = "Rate") then $t/Price/text() else ()},
             element rate_interval {if ($t/text() = "Rate") then $t/Interval/text() else ()}
           }
          }; declare function local:getChildren($e as node(), $pID as xs:integer?) as element()*
          {
           for $i in $e/child::Node
           let $ID := local:getID($i)
           let $c := local:getConditions($i)
           let $t := local:getTariff($i)
           return element r
           {
            element tag_id {$ID},
            element parent_tag_id {$pID},
            element tag_name {local-name($i)},
            element tag_text {$i/text()},
            element condtype1_from { $c/condtype1_from },
            element condtype1_to { $c/condtype1_to },
            element condtype2_type { $c/condtype2_type },
            element condtype2_number { $c/condtype2_number },
            element condtype3_from { $c/condtype3_from },
            element condtype3_to { $c/condtype3_to },
            element fee_price { $t/fee_price },
            element rate_price { $t/rate_price },
            element rate_interval { $t/rate_interval }
           }
            | local:getChildren($i,$ID)
          }; local:getChildren($d,())'
          passing xt.object_value as "d"
          columns tag_id           number        path 'tag_id',
                  parent_tag_id    number        path 'parent_tag_id',
                  tag_name         varchar2(50)  path 'tag_name',
                  tag_text         varchar2(50)  path 'tag_text',
                  condtype1_from   varchar2(100) path 'condtype1_from',
                  condtype1_to     varchar2(100) path 'condtype1_to',
                  condtype2_type   varchar2(100) path 'condtype2_type',
                  condtype2_number varchar2(100) path 'condtype2_number',
                  condtype3_from   varchar2(100) path 'condtype3_from',
                  condtype3_to     varchar2(100) path 'condtype3_to',
                  fee_price        number        path 'fee_price',
                  rate_price       number        path 'rate_price',
                  rate_interval    number        path 'rate_interval'
         ) x
    WHERE connect_by_isleaf = 1
    CONNECT BY prior tag_id = parent_tag_id
    START WITH parent_tag_id IS NULL
    ;
    
    TAG_TEXT                       CONDTYPE1_FROM   CONDTYPE1_TO   CONDTYPE2_TYPE   CONDTYPE2_NUMBER      CONDTYPE3_FROM   CONDTYPE3_TO    FEE_PRICE RATE_PRICE RATE_INTERVAL
    ------------------------------ ---------------- -------------- ---------------- --------------------- ---------------- -------------- ---------- ---------- -------------
    /Text/Child1/Child2            /XX//            /YY//          //0/             //12,34,56,89,0012/   ///Mon           ///Fri                 50         10            60
    /Text/Child1/DefaultRate       /XX//            /YY//          //0/             //12,34,56,89,0012/   ///              ///                  5000
     
    

    Here I used the SYS_CONNECT_BY_PATH function to aggregate the values in the pecking order. You can change the separator and use string manipulation functions more format the result.

    This can also be done directly in XQuery. So if you could answer the two questions above then I could show you how.

    Tags: Database

    Similar Questions

    • Flatten the recursive hierarchy

      Hello

      I am trying to flatten a recursive hierarchy like this table:

      Source:

      KEY... PARENT_KEY... NAME... LEVEL
      1 ........... (NULL)................... ABC............ 1
      2 .......... 1...........................123............2
      3 .......... 1...........................456............2
      4 ......... 3...........................xyz............. 3


      Target:

      KEY... NAME_LEVEL1... NAME_LEVEL2... NAME_LEVEL3
      1 ........ ABC...................... ABC...................... ABC
      2 ........ ABC...................... 123, 123
      3 ........ ABC...................... ... 456 456
      4 ........ ABC...................... 456... xyz


      I tried to use the CONNECT BY clause to flatten out it, but I'm stuck trying to get the third level. Here's my query:

      Select name, previous name
      source
      Start with parent_key is null
      connect by prior key = parent_key;

      Is it possible to get all the names of level 3 in a single query? Maybe connect you by is the wrong thing to use here?

      Thank you

      Hello

      CONNECTION is good for this, because it allows us to use the SYS_CONNECT_BY_PATH:

      SELECT     key
      ,     NVL (REGEXP_SUBSTR (SYS_CONNECT_BY_PATH (name, '/'), '[^/]+', 1, 1), name)     AS name_level_1
      ,     NVL (REGEXP_SUBSTR (SYS_CONNECT_BY_PATH (name, '/'), '[^/]+', 1, 2), name)     AS name_level_2
      ,     NVL (REGEXP_SUBSTR (SYS_CONNECT_BY_PATH (name, '/'), '[^/]+', 1, 3), name)     AS name_level_3
      FROM     source
      START WITH     parent_key     IS NULL
      CONNECT BY     parent_key     = PRIOR key
      ;
      

      This requires that you know some characters that never occurs in the name. I used "/" above, but you can use any character.

      I hope that answers your question.
      If not, post CREATE TABLE and INSERT statements for your sample data, as well as an explanation of how you get the desired results.

    • Filter the display of the source xml tree

      I have a treeview control that displays an xml structure.

      I have converted the XML into an XMLListCollection and ran a filter but it filters only the parent node, I need to filter the children of the treeview display.

      I can make a new xml code from the original that contains only the data I need, but I need information of XML to another window to display when selected. I don't want to just under a tree node.

      all ideas

      Thank you

      Yes, I found myself using this excellent datadescriptor
      http://snippets.dzone.com/posts/show/5673
      and change it to use interface XMLListCollection.

      This allows me to specify the node names to use as children, in this example simple visible will be displayed in the tree, invisible are not, but still be accessible in the XML.




    • A loop in the XML tree

      I posted this in the title of the general support Flex under a different title.

      What I'm trying to do is to loop through a XML structure that is used as a dataprovider for a menu bar. I couldn't find how to do this. Part of what I've tried so far is;

      I think I can get the data in XML format;

      MenuData = XML (menuLoad.lastResult);

      Once in this format, I was unable to find a way to loop (recursively, I presume) through the children to find the child with the attribute I need.

      I looked through the documentation, forums, blogs etc and no one (that I could find) contains an example of how to loop through an XML tree. Here is an example that does not work;

      traceNodes (MenuData);

      private void traceNodes(theNode:XML):void
      {
      (child var in theNode.)
      {
      trace (Child.Name ());
      trace (Child.Attributes ());
      traceNodes ([child] theNode);
      }
      }

      I really need help on this one.

      Paul

      Roberto:

      Thanks for the post, I was finally able to solve this problem. Here is my function to find a node in an xml tree. You could call it that;

      xmlMyNode = getXMLByAttribute (xmlMytree, "*", "label", "My Label");

      -----------------------------------------------------------

      private void getXMLByAttribute(xmlInputNode:XML,strNodeName:String,strAttribute:String,strAttributeVal_ue:String):XML
      {
      var xmlReturnNode:XML = null;
      for each (var xmlCurrentNode:XML of in xmlInputNode [strNodeName])
      {
      If (xmlCurrentNode.@[strAttribute] == strAttributeValue) return xmlCurrentNode;
      xmlReturnNode = getXMLByAttribute (xmlCurrentNode, strNodeName, strAttribute, strAttributeValue);
      If (xmlReturnNode! = null) break;
      }
      Return xmlReturnNode;
      }

      Paul

    • XML tree in memory after the closure of XmlResults

      Hello

      is it possible to have a tree xml parsed in memory that represents objects XmlValue after I closed the corresponding XmlResults. I want to have smth like nu.xom.Document (or any what analogues).
      The closest solution to you, I found so far becomes handle node and then rebuild XmlResults out of it by calling XmlContainer.getNode (java.lang.String). But it's not exactly what I want. I could not have access to the container object, or it might already be closed. The poor alternative is to get a chain of XmlValue.asString () and he feed such as XOM Builder.build (). But it is extremely inefficient.
      Are there better sth in his mind?

      P.S. I still want to recover documents lazily, but in the case of a get required an XML tree in memory.

      Thank you
      Vyacheslav

      Vyacheslav,

      What you want is coming in the next version of BDB XML. There is a new interface that is (currently) spec'd as:
      XmlResults XmlResults::copyResults()
      It makes a temporary copy of the result set that can be used regardless of the transaction in progress (or container).

      Kind regards
      George

    • Helps the Parseing XML

      Version: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production

      Hello

      I need assistance with an XML file to generate lines to insert into a table staged for further processing.

      There is an XML document that is loaded into a table in the database via a Web Service call.

      I need to query this table to get the XML code, loop through it to create folders, with the fields in a specific order and insert records into a table of staging.

      There are two columns that are not in the XML that are added during the process. I am including these tables as well.

      I know it is a bunch of "stuff", but I hope I've provided enough information to get help.

      The tables and insert queries:

      -This table contains the XML of the Web Service call

      CREATE TABLE exam_results
      (
      CLOB results_clob
      );

      INSERT INTO exam_results (results_clob)
      VALUES
      ("< result > < candidate > < ProgramCandidateID > 911221 < / ProgramCandidateID > < LastName > V361208 < / LastName > < FirstName > J361208 < / FirstName > < / candidate > < event > < ended > 1 < / filled > < CompleteDate > 2011 - 08 - 05T 10: 23:42.957 < / CompleteDate > < FormName > SSU11-05 < / FormName > < NumStarts > 2 < / NumStarts > < ProgramRegistrationID > SU0006510JV < / ProgramRegistrationID > < result > 564865 identifier < / result identifier >") < Sponsor > MySponsor < / sponsor > < StartTime > 2011 - 08 - 05T 08: 22:47.877 < / StartTime > < TestName > SSU11 < / TestName > < / Event > < start > < Start > < BrowserVersion > 8.0 < / BrowserVersion > < OperatingSystem > Windows NT 4.0 < / OperatingSystem > < / Start > < / begins > < Scores > < issues > < > < name > 105103 < / name > < SeqDelivered > 1 < / SeqDelivered > < response > 1 < / response > < key > 4 < / key > < seconds > 169.126 < / seconds > < Section > 1 < / Section > < / Question > < Question > < name > 261292 < / name > < SeqDelivered > 2 < / SeqDelivered > < answer > 3 < / response > < key > 3 < / key > < seconds > 97.984 < / seconds > < Section > 1 < / Section > < / Question > < Question > < name > 261241 < / name > < SeqDelivered > 3 < / SeqDelivered > < response > 3 < / response > < key > 3 < / key > < seconds > 87.579 < / seconds > < Section > 1 < / Section > < / Question > < Question > < name > 261451 < / name > < SeqDelivered > 4 < / SeqDelivered > < answer > 3 < / response > < key > 3 < / key > < seconds > 59.983 < / seconds (> < Section > 1 < / section > < / Question > < Question > < name > 264373 < / name > < SeqDelivered > 5 < / SeqDelivered > < response > 5 < / response > < key > 1 < / key > < seconds > 86.346 < / seconds > < Section > 1 < / Section > < / Question > < / Questions > < / Scores > < / result > ');

      -This table is to get 1 of the additional columns that must be included

      CREATE TABLE tracking_id_tbl
      (
      tracking_id NUMBER,
      customer_id NUMBER,
      launch_code VARCHAR2 (11)
      );

      INSERT INTO tracking_id_tbl (tracking_id, customer_id, launch_code)

      VALUES (557,2296267, 'SU0006510JV');

      -This table is to get the other extra column which must be included

      CREATE TABLE school_code_tbl
      (
      customer_id NUMBER,
      nb_id NUMBER,
      organization_id VARCHAR2 (8)
      );

      INSERT INTO school_code_tbl (customer_id, nb_id, organization_id)

      VALUES (2296267,911221, '12');

      -This table will receive the file created from the XML

      CREATE TABLE staging_tbl
      (
      results_data VARCHAR2 (4000)
      );

      To facilitate the XML file to read (we hope) here is a formatted version:

      < result >

      < candidate >

      < ProgramCandidateID > 911221 < / ProgramCandidateID >

      < name > V361208 < / LastName >

      J361208 < FirstName > < / name >

      < / candidate >

      < event >

      < finish > 1 < / completed >

      < completeDate > 2011 - 08 - 05T 10: 23:42.957 < / CompleteDate >

      SSU11-05 < FormName > < / FormName >

      < NumStarts > 2 < / NumStarts >

      < ProgramRegistrationID > SU0006510JV < / ProgramRegistrationID >

      ID of < result > 564865 < / ID results >

      < sponsor > MySponsor < / sponsor >

      < StartTime > 2011 - 08 - 05T 08: 22:47.877 < / StartTime >

      SSU11 < TestName > < / TestName >

      < / event >

      < start >

      < start >

      < > 8.0 BrowserVersion < / BrowserVersion >

      < OperatingSystem > Windows NT 4.0 < / OperatingSystem >

      < / start >

      < / starts >

      < scores >

      < questions >

      < question >

      < name > 105103 < / name >

      < SeqDelivered > 1 < / SeqDelivered >

      < response > 1 < / answer >

      < Key > 4 < / key >

      < seconds > 169.126 < / seconds >

      article <>1 < / Section >

      < / question >

      < question >

      < name > 261292 < / name >

      < SeqDelivered > 2 < / SeqDelivered >

      < response > 3 < / answer >

      < Key > 3 < / key >

      < seconds > 97.984 < / seconds >

      article <>1 < / Section >

      < / question >

      < question >

      < name > 261241 < / name >

      < SeqDelivered > 3 < / SeqDelivered >

      < response > 3 < / answer >

      < Key > 3 < / key >

      < seconds > 87.579 < / seconds >

      article <>1 < / Section >

      < / question >

      < question >

      < name > 261451 < / name >

      < SeqDelivered > 4 < / SeqDelivered >

      < response > 3 < / answer >

      < Key > 3 < / key >

      < seconds > 59.983 < / seconds >

      article <>1 < / Section >

      < / question >

      < question >

      < name > 264373 < / name >

      < SeqDelivered > 5 < / SeqDelivered >

      < response > 5 < / answer >

      < Key > 1 < / key >

      < seconds > 86.346 < / seconds >

      article <>1 < / Section >

      < / question >

      < / questions >

      < / scores >

      < / result >

      This XML file is for 1 card. There are several issues that are in the file. I reduced to only 5 is easier to see.

      The layout of the document to be inserted in the staging table is:

      Event.TestName

      Event.FormName

      Event.CompleteDate

      v_tracking_id

      Event.ProgramRegistrationID

      Event.StartTime

      Event.CompleteDate / * end * /.

      Candidate.LastName

      Candidate.FirstName

      Candidate.MiddleName (the middle name does not exist in the file XML then return null)

      Candidate.ProgramCandidateID

      v_school_code

      Candidate.CustomProperties.Answer (this does not exist in the file XML then return null)

      Event.ResultID

      Event.NumStarts

      Event.Completed

      Event.Sponsor

      Scores.Questions.Question.Name

      Scores.Questions.Question.Section

      Scores.Questions.Question.SeqDelivered

      Scores.Questions.Question.Key

      Scores.Questions.Question.Answer

      Scores.Questions.Question.Seconds

      Starts.OperatingSystem

      Starts.BrowserVersion

      The expected output is:

      INSERT INTO staging_tbl (results_data)
      VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,105103,1,1,4,1,169.126,Windows NT 4.0,8.0");

      INSERT INTO staging_tbl (results_data)
      VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,261292,1,2,3,3,97.984,Windows NT 4.0,8.0");

      INSERT INTO staging_tbl (results_data)
      VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,261241,1,3,3,3,87.579,Windows NT 4.0,8.0");

      INSERT INTO staging_tbl (results_data)
      VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,261451,1,4,3,3,59.983,Windows NT 4.0,8.0");

      INSERT INTO staging_tbl (results_data)
      VALUES ('SSU11,SSU11-05,08/05/2011,557,SU0006510JV,08:22:47,10:23:42,V361208,J361208,,911221,12,,564865,2,1,MySponsor,264373,1,5,1,5,86.346,Windows NT 4.0,8.0");

      The Questions/Question, is what makes a separate line if the values for the other fields would be the same for however many questions is in the XML file.

      That's what I've tried so far:

      DECLARE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             CURSOR get_results_cur
      IS
      SELECT results_clob
      Of exam_results;

      get_results_rec XMLTYPE.
      get_results_clob CLOB.
      NUMBER (38) v_count: = 1;


      v_result VARCHAR2 (32000);
      v_tracking_id tracking_id.tracking_id_tbl%TYPE;
      v_school_code organization_id.school_code_tbl%TYPE;

      BEGIN
      OPEN get_results_cur.
      SEEK get_results_cur INTO get_results_clob;
      CLOSE Get_results_cur;

      get_results_rec: = xmltype.createxml (get_results_clob);

      SELECT tracking_id
      school_code
      IN v_tracking_id
      v_school_code
      OF ti tracking_id_tbl
      JOIN school_code_tbl ON ti.customer_id = sc.customer_id sc
      WHERE ti.launch_code = get_results_rec. EXTRACT ('/ Result/Event/ProgramRegistrationID/text()').getstringval () AND)
      nb_id = get_results_rec. EXTRACT ('/ Result/Candidate/ProgramCandidateID/text()').getstringval ();)

      While get_results_rec. EXISTSNODE ('/ / result [' | v_count |]) ']') = 1
      LOOP
      v_result: =.
      (get_results_rec. EXTRACT ('/ results/event/TestName [' | v_count | / text () ']) .getstringval ())
      || ','
      || (get_results_rec. EXTRACT ('/ results/event/FormName [' | v_count | / text () ']) .getstringval ())
      || ','
      || ((get_results_rec. EXTRAIT ('/ résultats/événement/CompleteDate [' || v_count || / text () SUBSTR']) .getstringval ()), 1, 10)
      || ','
      || v_tracking_id
      || ','
      || (get_results_rec. EXTRACT ('/ results/event/ProgramRegistrationID [' | v_count | / text () ']) .getstringval ())
      || ','
      || ((get_results_rec. EXTRAIT ('/ résultats/événement/StartTime [' || v_count || / text () SUBSTR']) .getstringval ()), 12.8)
      || ','
      || ((get_results_rec. EXTRAIT ('/ résultats/événement/CompleteDate [' || v_count || / text () SUBSTR']) .getstringval ()), 12.8)
      || ','
      || (get_results_rec. EXTRACT ('/ result/candidate/name [' | v_count | / text () ']) .getstringval ())
      || ','
      || (get_results_rec. EXTRACT ('/ result/candidate/name [' | v_count | / text () ']) .getstringval ())
      || ',,'
      || -(get_results_rec. Extract('/result/candidate/MiddleName [' || v_count ||) '] / text () ') .getStringVal ()); ',' ||
      (get_results_rec. EXTRACT ('/ result/candidate/ProgramCandidateID [' | v_count | / text () ']) .getstringval ())
      || ','
      || v_school_code
      || ','
      || (get_results_rec. EXTRACT ('/ results/event/result identifier [' | v_count | / text () ']) .getstringval ())
      || ','
      || (get_results_rec. EXTRACT ('/ results/event/NumStarts [' | v_count | / text () ']) .getstringval ())
      || ','
      || (get_results_rec. EXTRACT ('/ results/event/completed [' | v_count | / text () ']) .getstringval ())
      || ','
      || (get_results_rec. EXTRACT ('/ results/event/sponsor [' | v_count | / text () ']) .getstringval ());
      || ','

      -Add the results of the first question

      || ','
      || (get_results_rec. EXTRACT ('/ result, departures, Start, OperatingSystem [' | v_count | / text () ']) .getstringval ())
      || ','
      || (get_results_rec. EXTRACT ('/ result, departures, Start, BrowserVersion [' | v_count | / text () ']) .getstringval ());

      v_count: = v_count + 1;

      INSERT INTO staging_tbl (results_data)
      VALUES (v_result);

      END LOOP;
      END;

      What can clear?

      Thank you

      Joe

      You have several questions in the XML, so when flattened document you will have several lines trying to extract in v_result.  Where the error.  You will need to either loop

      for rec in (select... from XMLTable...)

      loop

      insert into staging_tbl...

      end loop;

      or make an insert select

      insert into staging_tbl (results_data)

      Select...

      from XMLTable...

    • XMLList to the external XML file

      Hi all

      I'm new to Flex, but I was impressed with it so far. I was able to create a simple, where things application like navigation trees and the data in the table were populated based on XML stored in tags mx:XMLList inside the main document. To clean things up, I thought that I would like to move the data in external XML files. I copied the data files and verified that the data has always been a single top-level node. Then, noted that mx:XMLList does not support the attribute 'source', so I converted to the use of mx:XML within the application mxml tags. Compiles the application now, but all of the XML hierarchy displayed in the form of a single node, instead of being analyzed in the tree nodes. No idea what I'm missing here? And thanks in advance for the noob easy going. ;-)

      -Josh

      Yet once, answered myself for posterity.

      For the tree data, the top node is implied, so I just had to change the dataProvider to {deviceTree.node}. For the data in the table, it was a little more difficult, where rather to link using a tag, I rather linked to it as a and then created a where the source is specified as the {[id XML]. [node]}. (once again the top node was already implicit)

    • I created a new library of more new playlists but cannot find the Library.xml file

      Hello

      I'm going to re - build my iTunes files from scratch, a kind of decennial event 'spring clean '. I have created a new library by using the command, click on application startup, and then began to rebuild new reading lists in the application. I can see the folder newly created the library that contains the new "iTunes Library.itl" file BUT I don't see that the iTunes Music Library.xml file. " There certainly must be one to save the data of the playlist, and probably "Get Info" should reflect today date' today... I don't see older versions.

      Although everything seems to work perfectly I don't want to have to re - visit the construction of Playlists from scratch for the next ten years! Can anyone suggest what happened to the .xml file?

      Thanks and greetings

      You can create an .xml on iTunes/file/library/Export library file and gives you the opportunity to put the Library.xml file in your iTunes Media folder - or anywhere you like.

      If you need to rebuild your playlists, you can go to iTunes, file, library, import playlist and select the .xml file.

      Normally, you do not see the .xml file in your iTunes folder.

    • "The document is not valid. The index.xml file is missing.

      I suddenly can't open one of my docs of numbers. I get a msg "'name of the doc' document is not valid. The index.xml file is missing.  I literally had the open document this morning without problem, closed, tried to reopen and now I get this msg... all in the same session of the computer. It began not after an update or anything like that, right in the middle of a session of the computer.  You seem to affect all the docs of numbers.  I can't open an any of them now.  I am running OS X El Capitan Version 10.11 and numbers 09, Version 2.1.

      Hi jg,.

      The case usual this message, it is that the document has been opened in numbers version 3.xx, which converts it into a new file version that uses the file index.xml internal requested by Numbers ' 09.

      You have 3 numbers installed on your machine? This file has already been opened in this application?

      The file was saved to iCloud or opened by the iOS version numbers or numbers for iCloud?

      Recommended 'cure' is to open the file using the 3 numbers, then save as... or export to format Numbers ' 09. As a result, remember numbers to quit smoking (v3) - menu numbers > numbers to quit smoking; by clicking on the red light closed the file, but doesn't end numbers. So avoid open numbers files by double-clicking on the file itself.

      Instead, start Numbers ' 09 (v2.3) and open the file in the application.

      Kind regards

      Barry

    • Extracting XML error. The XML file that is assigned in the configuration.xml is either incorrect or damaged.

      1. some web pages gives "error extracting XML. The XML file that is assigned in the configuration.xml is wrong or corrupt.

      2 Youtube gives, after having pressed the button start, message "an error has occurred. Please try again later.
      Even youtube opening page with IE, there is no problem.

      3. scrolling on Mozilla firefox pages only works with the sidebar not with the mouse wheel.

      Other user accounts on this computer is not these problems.

      BR Juha

      This can be caused by a recent update of Flash 11.3.

      See:

    • After invoking the RSS "Subscribe to this page", then using the previous/next buttons, Firefox displays the raw XML code

      1) go to the URL http://bionsmalleyassoc.com/BSA_jsp/MU_test
      (2) select Bookmarks-> subscribe to this page
      3) press the previous button
      4) press the next button
      Note that him 'subscribe to this page' does not reappear. However, Firefox incorrectly displays the raw for the RSS XML, as if he forgot that the destination forward is an RSS feed.

      This same sequence in IE9 or Safari 5.1 works fine as expected. In addition, Firefox has the same problem in MAC OSX 10.6

      Works for me now, you probably recharge and bypass the cache (Ctrl + F5) to get a new copy of this page RSS.

    • Error message: the index.xml file is missing.

      I am trying to open a 'Numbers' file, which is stored in Dropbox in the cloud.

      I know there are some discussions about this already on this support group but they all suggest to back up files in Time Machine. I use Dropbox for years with no problems, but today I tried to open a file of numbers in Dropbox and received the message: "the index.xml file is missing." I have 2 other computers and an iPhone 6 and the file opens on them perfectly so my problem is with a single computer.

      I tried pulling the file from Dropbox on the desktop of another computer and then send this file to me as an attachment. I opened this file on the computer sends me questions, drag the file on the desktop and when I tried to open the file, I got the same message.

      It's just strange that it will not be open on computers.

      Any advise?

      Thank you, Tony

      Hi Tony,.

      This is somethng that occurs when you try to open a file of 3 numbers to 2 digits ('09). Make sure that you leave 2 numbers and then try to open the file of numbers 3. That should do it.

      Quinn

    • The index.xml file required is missing. Cannot open documents. 10.10.5 sys

      The index.xml file required is missing. Cannot open documents. 10.10.5 sys

      You have two versions of installed Pages, where the Pages ' 09 document format use it internal document index.xml, and all Pages v5 releases use a different document format that does not incorporate the index.xml file. If you have Pages ' 09 running without window, and double-click a v5 document Pages, you will get a Pages ' 09 dialog box indicating that the index.xml file is missing.

      Exit Pages ' 09 and then double click on the document to open correctly in your version of v5 Pages.

    • The index.xml file is missing

      The index.xml file is missing - it appears when you try to open a Pages document

      Is - this information that I already posted a few minutes ago, help you solve this problem?

    • I get a message that says... your version of internet explore is obsolete to run the latest XML parser. I cannot print with my printers. I have a XP SP3, 5 years old. It's time to upgrade to windows 7

      I get a message that says... your version of internet explore is obsolete to run the latest XML parser. I cannot print with my printers. I have a XP SP3, 5 years old. It's time to upgrade to windows 7

      What version of IE are you using?

      The current version is IE8 - http://www.microsoft.com/nz/windows/internet-explorer/default.aspx

      IE9 (is still in beta).

      Harold Horne / TaurArian [MVP] 2005-2011. The information has been provided * being * with no guarantee or warranty.

    Maybe you are looking for