Extract XML data online on a regular basis.

Hi guys, I am new to the PL/SQL and im kind of stuck here, what I'm trying to Edifier is:

There is this file online: [indicadores.xml | http://www.dof.gob.mx/indicadores.xml], which contains data from Exchange rate I need to use.

I just need to get the < item > elements.

This feed is updated every day, so what I intend to do is to recover this data each day at midnight and store the data in a single table with the following structure:

CREATE TABLE RATES
(
title VARCHAR2 (CHAR) NOT NULL,
Description NUMBER NOT NULL,
pubDate DATE NOT NULL,

);

I don't know if it is possible, nor how, I was checking some of the messages on this forum, but most of them parse a local XML file and not a online, also I do not know how can I do on a daily basis.

Any help will be greatly appreciated!

Thank you!

José Manuel Hurtado Portugal

In this case, you can also do

SQL> select extractvalue(t.x,'//dc:date', 'xmlns:dc="http://purl.org/dc/elements/1.1/"') datepub,
       extractvalue(t.x,'//cb:value', 'xmlns:cb="http://staging.bis.org/rss-cb/1.0/') valuepub,
       extractvalue(t.x,'//cb:rateName', 'xmlns:cb="http://staging.bis.org/rss-cb/1.0/') ratename
  from (select httpuritype ('http://www.banxico.org.mx/rsscb/rss?BMXC_canal=cetes').getxml () x from dual) t
/
DATEPUB                        VALUEPUB                       RATENAME
------------------------------ ------------------------------ ------------------------------
2010-11-30T11:37:29-06:00      4.35                           CETES28
1 row selected.

Tags: Database

Similar Questions

  • extract xml data in the collection

    Hello

    I want to extract xml data in a collection of collection


    could any body you tell me if we succeed in sql
    ex:

    declare
    type t_code is table of number;
    type r_rec is record (c_name varchar2 (100),)
    c_code vrachar2 (100),
    c_code_number t_code);
    type t_rec is the table of the r_rec;

    l_xml xmltype: = xmltype (')

    < body >
    <>campaign
    < code > < code > CAMP_1
    < description > Campaign_1 < / description >
    < rateplans >
    < rateplanCode > 1 < / rateplanCode >
    < rateplanCode > 2 < / rateplanCode >
    < rateplanCode > 3 < / rateplanCode >
    < / rateplans >
    < / campaign >
    <>campaign
    < code > < code > CAMP_2
    < description > Campaign_2 < / description >
    < rateplans >
    < > 11 rateplanCode < / rateplanCode >
    < > 22 rateplanCode < / rateplanCode >
    < rateplanCode > 33 < / rateplanCode >
    < / rateplans >
    < / campaign >
    <>campaign
    < code > < code > CAMP_3
    < description > Campaign_3 < / description >
    < rateplans >
    < > 111 rateplanCode < / rateplanCode >
    < > 222 rateplanCode < / rateplanCode >
    < > 333 rateplanCode < / rateplanCode >
    < / rateplans >
    < / campaign >
    < result >
    < > 00 resultCode < / resultCode >
    < resultText > success < / resultText >
    < / result >
    (< / body > ');

    Start

    Select / * logic exrat value of xml in the final collection * /.
    Double;

    end;

    I want data in the model in my final collection t_rec

    CAMP_1, Campaign_1, nested_table (1,2,3)
    CAMP_2, Campaign_2, nested_table (11,22,33)
    CAMP_3, Campaign_3, nested_table (111,222,333)

    Published by: 948596 on May 17, 2013 05:17

    Like this

    SQL> declare
      2       type t_code is table of number ;
      3       type r_rec is record
      4       (
      5          c_name varchar2(100),
      6          c_code varchar2(100),
      7          c_code_number t_code
      8       );
      9       type t_rec is table of r_rec ;
     10       l_rec t_rec := t_rec();
     11       l_xml xmltype := xmltype
     12                        ('
     13                           
     14                           
     15                           CAMP_1
     16                           Campaign_1
     17                           
     18                           1
     19                           2
     20                           3
     21                           
     22                           
     23                           
     24                           CAMP_2
     25                           Campaign_2
     26                           
     27                           11
     28                           22
     29                           33
     30                           
     31                           
     32                           
     33                           CAMP_3
     34                           Campaign_3
     35                           
     36                           111
     37                           222
     38                           333
     39                           
     40                           
     41                           
     42                           00
     43                           Success
     44                           
     45                           '
     46                        ) ;
     47  begin
     48       for i in (
     49                 select rownum id
     50                      , t1.code
     51                      , t1.description
     52                      , t2.rate_plan_code
     53                      , row_number() over(partition by t1.code order by t2.rate_plan_code) rno
     54                   from xmltable
     55                        (
     56                             '/body/campaign' passing l_xml
     57                             columns
     58                               code        varchar2(100) path 'code',
     59                               description varchar2(100) path 'description',
     60                               rate_plans  xmltype       path 'rateplans'
     61                        ) t1
     62                      , xmltable
     63                        (
     64                             '/rateplans/rateplanCode' passing t1.rate_plans
     65                             columns
     66                               rate_plan_code varchar2(100) path '.'
     67                        ) t2
     68                )
     69       loop
     70            if i.rno = 1 then
     71               l_rec.extend;
     72               l_rec(l_rec.count).c_name := i.description;
     73               l_rec(l_rec.count).c_code := i.code;
     74               l_rec(l_rec.count).c_code_number := t_code();
     75            end if;
     76            l_rec(l_rec.count).c_code_number.extend;
     77            l_rec(l_rec.count).c_code_number(i.rno) := i.rate_plan_code;
     78       end loop;
     79       for i in 1..l_rec.count
     80       loop
     81          dbms_output.put_line(l_rec(i).c_code || '  ' || l_rec(i).c_name);
     82          for j in 1..l_rec(i).c_code_number.count
     83          loop
     84             dbms_output.put_line(l_rec(i).c_code_number(j));
     85          end loop;
     86       end loop;
     87  end;
     88  /
    CAMP_1  Campaign_1
    1
    2
    3
    CAMP_2  Campaign_2
    11
    22
    33
    CAMP_3  Campaign_3
    111
    222
    333
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    
  • Extract XML data using XML table NULL recovery

    Hello

    I use XMLtable to recover data using XMLtable

    XML

    "< env:Envelope xmlns:env = ' http://schemas.xmlsoap.org/SOAP/envelope/ ">

    < env:Header > < / env:Header >

    < env:Body >

    " < = Xmlns:ns1 CreditBureauResponse ' http://www.example.org "xmlns =" " http://www.example.org ">

    < ns1:Body >

    < ns1:MGResponse > & lt; MGResponse xmlns = "urn: crif - messagegateway:2006 - 08-23" > & lt; U2:AUE_RES xmlns:u2 = "urn: AUE" > & lt; U2:response > & lt; U2:CBApplicationId > 123456789 & lt; / u2:CBApplicationId > & lt; U2:ProviderApplicationNo > 123 & lt; / u2:ProviderApplicationNo > & lt; U2:PreviousPhase > D & lt; / u2:PreviousPhase > & lt; U2:ActualPhase > D & lt; / u2: ActualPhase > & lt; U2:ApplicationDeleted > 0 & lt; / u2:ApplicationDeleted > & lt; / u2:Response > & lt; / u2:AUE_RES > & lt; / MGResponse > < / ns1:MGResponse >

    < / ns1:Body >

    < / CreditBureauResponse >

    < / env:Body >

    "< / env:Envelope >.

    I would like to know where I am going wrong

    SELECT x1.*

    OF tmp_xml_aue t.

    XMLTABLE (XMLNAMESPACES ('http://schemas.xmlsoap.org/soap/envelope/"as"env","http://www.example.org"as 'ns1", default'http://www.example.org'), )

    ' / env:Envelope / env:Body / CreditBureauResponse' T.OBJECT_VALUE by the WAY

    columns MGRESPONSE xmltype PATH "ns1:Body/ns1:MGResponse/text()") X 1,

    XMLTABLE (XMLNAMESPACES ("urn: crif - messagegateway:2006 - 08-23' as"v1", default" urn: AUE' '), ' / MGResponse/AUE_RES ' PASSAGE xmltype (DBMS_XMLGEN.convert (X 1.) MGRESPONSE. GETCLOBVAL(), 1))

    columns CBAPPLICATIONID varchar2 (15) WAY "response/CBApplicationId.

    ) X 2;

    Hello

    I saw your question and I hope that the link below will help you solve your solution:

    https://Oracle-base.com/articles/Misc/XMLTable-query-XML-data-from-SQL

    If there are problems more made me know I'll like you the exact solution for your query.

    Kind regards

    Vinoth.

  • Using EXTRACT XML data extraction

    Hi, I have a XML file where I want to analyze the fields in a table in DB:

    <? XML version = "1.0" encoding = "UTF-8"? >
    < FIXML > < batch > < MktDataFull BizDt = '2012-07-13' > < Instrmt Sym = "JCPRXU" ID = "JCPRXU" Desc = "JCP.SR. XR. «USD"SecTyp ="CD"Src ="H"subtype = MMY" S "="201209"MatDt = ' 2012-09-20" Mult = Exch "0.01" = "CMD" UOM = "CTL" UOMCcy = "USD" UOMQty = "1" PxUOM = "IPNT" ValMeth = "CD" CpnRt = "1.0" IntAcrl = ' 2012-06-20 ' CpnPmt = ' 2012-09-20 ' NotnlPctOut = "100.0" Snrty = 'SR' RstrctTyp = 'XR' DayCntMeth = "ACT/360" tenor = "0 M" > < DITTA HELP = "US708130AC31" AltIDSrc = "105" / > < HELP AltID = "JCP.SR." "" ""» XR. USD.12U.100"AltIDSrc ="101"/ > < HELP DITTA = '1 201209 JCPRXU' AltIDSrc = 'H' / > < DITTA HELP ="1 201209 JCPRXU"AltIDSrc ="100"/ > < Evnt EventTyp ="5"Dt ="2008-09-19"/ > < Evnt EventTyp = '7' Dt = '2012-09-19' / > < Evnt EventTyp ="19"Dt ="2012-10-05"/ > < Evnt EventTyp ="100"Dt ="2012-07-16"/ > < Evnt EventTyp = '8' Dt ="2012-07-14"/ > < Evnt EventTyp = '9' Dt = '2012-09-20' / > < Evnt EventTyp ="101"Dt = '2012-03-20' / > < Evnt EventTyp ="102"Dt ="2008-09-20"/ > < Evnt EventTyp = « 103 » Dt = « 2008-09-22 » / >< Evnt EventTyp = « 104 » Dt = « 2012-09-19 » / >< Evnt EventTyp = « 111 » Dt = « 2012-09-20 » / >< Evnt EventTyp = « 112 » Dt = « 2012-06-20 » / >< Evnt EventTyp = « 113 » Dt = « 2012-03-20 » / >< Evnt EventTyp = « 114 » Dt = « 2012-07-12 » / >< Evnt EventTyp = « 115 » Dt = « 2012-07-16 » / >< / Instrmt >< complet Typ = « 6 » Px = Mkt « 99.7433368 » = « CMD » QCond = « 6 » PxTyp = « 1 » OpenClsSettlFlag = « 1 » >< / Full >< complet Typ = « 6 » Px = « 234.5254 » Mkt = QCond « CMD » = « 6 » PxTyp = « 6 » ' OpenClsSettlFlag = '1' > < / Full > < full Typ = "Y" Px = Mkt "40.0" = 'CMD' PxTyp = '1' OpenClsSettlFlag = '1' > < / Full > < full Typ = '6' Px = "234.5212" Mkt = QCond 'CMD' = '7' PxTyp = '6' OpenClsSettlFlag = '1' > < / Full > < full Typ = Mkt "B" = 'CMD' OpenClsSettlFlag = '4' Sz = '0' > < / Full > < full type = 'C' Mkt = 'CMD' OpenClsSettlFlag = '4' Sz = '0' > < / Full > < full Typ = 'z' Px = Mkt '0.18' = 'CMD' PxTyp = '1' OpenClsSettlFlag = '1 '. > < / full > < full Typ = 'y' Px = "0.1899965" Mkt = QCond 'CMD' = '6' PxTyp = '5' OpenClsSettlFlag = '1' > < / Full > < InstrmtExt > < Attrb Typ = '100' Val = '24' / > < Attrb Typ = '101' Val = '0' / > < Attrb Typ = '109' Val = '0' / > < Attrb Typ = '103' Val = '24' / > < Attrb Typ = '102' Val = '24' / > < Attrb Typ = '110' Val = '3' / > < Attrb Typ = '29' Val = 'Y' / > < Attrb Typ = '112' Val = 'Y ' /. > < / InstrmtExt > < / MktDataFull > < / batch > < / FIXML >


    Right now, I'm just trying to extract the first 3 fields, BizDt, Bal and id I use to analyze the following:


    SELECT
    Extract (value (p), '/BizDt') .getStringVal () AS DATE_,.
    Extract (value (p), ' /Instrmt/Sym').getStringVal (AS SYMBOL),)
    Extract (value (p), ' /Instrmt/ID').getStringVal () AS ID_)

    OF s TABLE_NAME.
    TABLE (XMLSEQUENCE (Extract (xmlType.createXml (s.CDS_CLOB), ' FIXML/batch/MktDataFull / *'))) p
    WHERE s.ID_ = 1

    But I get nothing back. My guess is the because the XML data does not have opening tags and formal closing, because if I change my XML like this:

    <? XML version = "1.0" encoding = "UTF-8"? >
    < FIXML > < batch > < MktDataFull > < BizDt > 2012 - 07 - 13 < / BizDt > < Instrmt > < Sym > JCPRXU < / Sym > < ID > JCPRXU < /ID > < Desc > JCP.SR. XR. USD < / Desc > < SecTyp > CD < / SecTyp > < / Instrmt > < / MktDataFull > < / batch > < / FIXML >

    I was able to get the data. Therefore, in order so solve this problem, what should I do with my original XML? Can I format the tags?

    Thank you

    When you nest xsl: for each of the elements, the select expression is evaluated in the context of the enclosing instance.

    Consider this:

    
      
    

    This means you are trying to match items complete as children Instrmt, that is not correct, because they are actually siblings.
    In the same goes for HELP, Evnt etc.

    I don't know what kind of structure you want.
    Caps all does not much sense given that groups of brothers of repeat items that have no apparent correlation between them. Essentially, you end up with a big Cartesian product.

    I would approach this by storing repeated elements in different tables with a parent/child relationship to preserve the hierarchical nature of the data (if necessary).

  • Extracting XML data limit?

    Hi all

    Can someone help with the data limit for retrieving XML from a text field?

    Scenario: I have a text field with the limit set for the 1000 characters. Can you please let me know if there is any limitation extracting XML with a text field with 1000 characters?


    Thank you
    Yassine

    Hi John,

    I have not met a deadline, I had 8000-character text fields (as much as can fit on an A4 page) and I had pictures of 4 MB in a data node.

    Concerning

    Bruce

  • Extract XML data to a text box

    How could I get the XML data a box?

    Course code: (it will not display anything!)

    var dyoXML:XML = new XML();
    dyoXML.ignoreWhite = true;

    dyoXML.onLoad = {function (success)}
    {if (Success)}
    disemail. Text = This;
    }
    }

    dyoXML.load ("http://www.myweb.com/mails.php");

    you not set $fin in your php file.  use:

    $fin = $_POST ['end'];

    to define it.  and you should be specifying the POST method to send data to your php file.  (unless you send end via the query string that you aren't.)

  • using XPath with SQL to extract XML data

    Given the data like this:
    <?xml version="1.0"?>
    <ExtendedData>
       <Parameter name="CALLHOLD"><BooleanValue>true</BooleanValue></Parameter>
    
      <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
    
      <Parameter name="ALLCF"><BooleanValue>true</BooleanValue></Parameter>
    
      <Parameter name="RealProv"><BooleanValue>false</BooleanValue></Parameter>
    
    </ExtendedData>
    I usually use extractValue as shown below, for example function to extract the value for the last parameter in the above data, for example:
    select extractValue(extended_data,'/ExtendedData/Parameter[@name="RealProv"]/BooleanValue') "my_column_alias" from table
    Any ideas on how can I return the value of the parameter xsi: Nil for that node:
    <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
    I would like to extract the
    true
    in
    xsi:nil="true"
    ...

    Thank you

    Published by: HouseofHunger on May 15, 2012 14:13

    Published by: HouseofHunger on May 15, 2012 14:13

    ExtractValue() has a third parameter, that we can use to declare the namespace mappings:

    SQL> with sample_data as (
      2    select xmltype('
      3  
      4    true
      5    
      6    true
      7    false
      8  ') doc
      9    from dual
     10  )
     11  select extractvalue(
     12           doc
     13         , '/ExtendedData/Parameter[@name="BARRING_PASSWORD"]/@xsi:nil'
     14         , 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
     15         )
     16  from sample_data
     17  ;
    
    EXTRACTVALUE(DOC,'/EXTENDEDDAT
    --------------------------------------------------------------------------------
    true
     
    

    If you are on 11.2.0.2 and upward, extractvalue() is obsolete.
    Must use XMLCast/XMLQuery instead:

    SQL> with sample_data as (
      2    select xmltype('
      3  
      4    true
      5    
      6    true
      7    false
      8  ') doc
      9    from dual
     10  )
     11  select xmlcast(
     12           xmlquery('/ExtendedData/Parameter[@name="BARRING_PASSWORD"]/@xsi:nil'
     13            passing doc
     14            returning content
     15           ) as varchar2(5)
     16         )
     17  from sample_data
     18  ;
    
    XMLCAST(XMLQUERY('/EXTENDEDDAT
    ------------------------------
    true
     
    

    Note: the prefix xsi is predefined when using Oracle's XQuery, so in this case we must explicitly declare.

    Published by: odie_63 on May 15, 2012 15:23

  • Extract XML Data using XMLTable 1-n relationship data

    Dear all,

    The following query works well.
    with t as (select XMLType('<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
       <env:Header/>
       <env:Body>
          <nm:CustomerCRMByIDResponse xmlns:nm="http://sap.com/xi/CRM/Global2" xmlns:prx="urn:sap.com:proxy:DCT:/1SAI/TAS57DF0B317943DEAE3C49:702">
             <MessageHeader/>
             <BusinessPartner>
                <InternalID>2200117598</InternalID>            
                <AddressInformation>
                   <UUID>51471396-9ae8-3cc0-e100-80000a031a28</UUID>
                                        <DefaultIndicator>true</DefaultIndicator>
                   <Address>
                      <PostalAddress>
                         <CountryCode>DE</CountryCode>
                         <CountryName>Country Name</CountryName>
                      </PostalAddress>
                      <Telephone>
                         <Number>
                            <SubscriberID>0711/123456</SubscriberID>
                            <ExtensionID>0</ExtensionID>
                            <CountryCode>DE</CountryCode>
                            <CountryDiallingCode>+49</CountryDiallingCode>
                            <CountryName languageCode="de">Country Name</CountryName>
                         </Number>
                         <UsageDeniedIndicator>false</UsageDeniedIndicator>
                         <MobilePhoneNumberIndicator>false</MobilePhoneNumberIndicator>
                         <SMSEnabledIndicator>false</SMSEnabledIndicator>
                         <DefaultIndicator>true</DefaultIndicator>
                      </Telephone>
                      <Telephone>
                         <Number>
                            <SubscriberID>0711/999999</SubscriberID>
                            <CountryCode>DE</CountryCode>
                            <CountryDiallingCode>+49</CountryDiallingCode>
                            <CountryName languageCode="de">Country Name</CountryName>
                         </Number>
                         <UsageDeniedIndicator>false</UsageDeniedIndicator>
                         <MobilePhoneNumberIndicator>true</MobilePhoneNumberIndicator>
                         <SMSEnabledIndicator>true</SMSEnabledIndicator>
                         <DefaultIndicator>false</DefaultIndicator>
                      </Telephone>
                      <Facsimile>
                         <Number>
                            <SubscriberID>0711/999888</SubscriberID>
                            <ExtensionID>99</ExtensionID>
                            <CountryCode>DE</CountryCode>
                            <CountryDiallingCode>+49</CountryDiallingCode>
                            <CountryName languageCode="de">Country Name</CountryName>
                         </Number>
                         <UsageDeniedIndicator>false</UsageDeniedIndicator>
                         <DefaultIndicator>true</DefaultIndicator>
                      </Facsimile>
                      <EMail>
                         <URI>[email protected]</URI>
                         <UsageDeniedIndicator>false</UsageDeniedIndicator>
                         <DefaultIndicator>true</DefaultIndicator>
                      </EMail>
                      <EMail>
                         <URI>[email protected]</URI>
                         <UsageDeniedIndicator>false</UsageDeniedIndicator>
                         <DefaultIndicator>false</DefaultIndicator>
                      </EMail>
                      <Web>
                         <URI>www.xyz.com</URI>
                         <UsageDeniedIndicator>false</UsageDeniedIndicator>
                         <DefaultIndicator>true</DefaultIndicator>
                      </Web>
                   </Address>
                </AddressInformation>
                <AddressInformation>
                   <UUID>514a519b-39a2-4890-e100-80000a031a28</UUID>
                                        <DefaultIndicator>false</DefaultIndicator>
                   <Address>
                      <PostalAddress>
                         <CountryCode>AT</CountryCode>
                         <CountryName>Österreich</CountryName>
                      </PostalAddress>
                   </Address>
                </AddressInformation>
             </BusinessPartner>
          </nm:CustomerCRMByIDResponse>
       </env:Body>
    </env:Envelope>') xml_data from dual)
    SELECT xmlresponse.*
    FROM t, XMLTable(Xmlnamespaces('http://www.w3.org/2003/05/soap-envelope' AS "env",
                                                                      'http://sap.com/xi/CRM/Global2' AS "nm",
                                                                      'urn:sap.com:proxy:DCT:/1SAI/TAS57DF0B317943DEAE3C49:702' AS "prx"
                                                                      ),
                                            'for $BusinessPartner in /env:Envelope/env:Body/nm:CustomerCRMByIDResponse/BusinessPartner                  
                        return $BusinessPartner'
                                            PASSING xml_data
                                            COLUMNS
                                            Internalid Varchar2(4000) Path 'InternalID'  
                                            ) xmlresponse;
    As you can see, a "BusinessPartner" can have several "AddressInformation.
    and a "AddressInformation" can have several 'phone '.

    Can anyone suggest me how can I retrieve both InternalID & UUID in a query? For example above output should look as follows...
    InternalID UUID 
    2200117598 51471396-9ae8-3cc0-e100-80000a031a28
    2200117598 514a519b-39a2-4890-e100-80000a031a28
    Thank you much in advance.

    Kind regards
    Hari

    Here is a basic example of a method to achieve what you need

    SELECT xmlresponse.Internalid, xml2.uuid
      FROM t,
           XMLTable(Xmlnamespaces('http://www.w3.org/2003/05/soap-envelope' AS "env",
                                  'http://sap.com/xi/CRM/Global2' AS "nm"
                                 ),
                    '/env:Envelope/env:Body/nm:CustomerCRMByIDResponse/BusinessPartner'
                    PASSING xml_data
                    COLUMNS
                    Internalid   Varchar2(20) Path 'InternalID',
                    addrinfoxml  XMLType      PATH 'AddressInformation'
                   ) xmlresponse,
           XMLTable('/AddressInformation'
                    PASSING xmlresponse.addrinfoxml
                    COLUMNS
                    UUID         Varchar2(80) Path 'UUID'
                   ) xml2;
    

    Changes:
    I deleted one of the namespaces that you include those who are included in a XPath statement.
    I've shortened your data types.
    I went for the simple XMLTable joined an XMLTable, instead of a single XMLTable approach using a FLWOR statement.
    You can include the addrinfoxml in your SELECTION list column to see the data passed between the two if you wish.

    Addition:
    Here is an approach for a single XMLTable.

    SELECT xmlresponse.*
      FROM t,
           XMLTable(Xmlnamespaces('http://www.w3.org/2003/05/soap-envelope' AS "env",
                                  'http://sap.com/xi/CRM/Global2' AS "nm"
                                 ),
                    'for $BP in /env:Envelope/env:Body/nm:CustomerCRMByIDResponse/BusinessPartner
                      for $ai in $BP /AddressInformation
                       return {$BP/InternalID}{$ai/UUID}'
                    PASSING xml_data
                    COLUMNS
                    Internalid   Varchar2(20) Path 'InternalID',
                    UUID         Varchar2(80) Path 'UUID'
                   ) xmlresponse;
    

    Published by: A_Non on March 25, 2013 09:41
    Added in the XQuery solution

  • Extraction of XML data

    Hello

    I have a requirement to extract data from XML and insert in a custom table.

    XML structure is

    < A >

    < Column1 >

    < Column2 >

    < Column3 >

    < Column4 >

    < column > 5

    < A >

    < A1 >

    < Column1 >

    < Column2 >

    < Column3 >

    < Column4 >

    < column > 5

    < A1 >

    .

    .

    .

    .

    < a >

    < Column1 >

    < Column2 >

    < Column3 >

    < Column4 >

    < column > 5

    < a >


    I need to extract all the values in the column and insert it into a custom table.

    Number of nodes one will increase every day, and columns can be of the order of 50-100.


    With the help of EXTRACTVALUE and bulk collect I m doing this process, but taking almost 2 hours for the processing of 3000 records.


    Please let me know is there better way (in terms of performance) to extract XML data?


    Thank you

    Kumar.

    Why the node is called as A1, A2... One? Why can it not be Just A? Here's an example of how to represent XML report and analyzed data to a relational structure.

    SQL> with t
      2  as
      3  (
      4  select xmltype
      5         (
      6  '
      7      
      8           1
      9           ram
     10           01-01-2016
     11           10000
     12      
     13      
     14           2
     15           karthick
     16           01-01-2016
     17           10000
     18      
     19      
     20           3
     21           subha
     22           01-01-2016
     23           10000
     24      
     25      
     26           4
     27           vimal
     28           01-01-2016
     29           10000
     30      
     31      
     32           5
     33           vijay
     34           01-01-2016
     35           10000
     36      
     37  
    ' 38 ) xmldata 39 from dual 40 ) 41 select t1.* 42 from t 43 , xmltable 44 ( 45 '/table/row' passing xmldata 46 columns 47 empno number path 'empno', 48 ename varchar2(10) path 'ename', 49 doj varchar2(10) path 'doj', 50 sal number path 'sal' 51 ) t1; EMPNO ENAME DOJ SAL ---------- ---------- ---------- ---------- 1 ram 01-01-2016 10000 2 karthick 01-01-2016 10000 3 subha 01-01-2016 10000 4 vimal 01-01-2016 10000 5 vijay 01-01-2016 10000
  • Can I create an XSD from XML data into a CLOB?

    Environment:


    Oracle 11.2.0.3 EE on Solaris.


    Highly an XML newbie so please be nice!

    I spent the past few days pouring through the documentation and various articles, including this one, but... I need help.

    I am trying to extract XML data stored in a CLOB and produce a flat file for the user's consumption.

    They sent me what they think is the XSD for XML data, but when I look at the data in the CLOB I don't see tags in the XSD.

    I would like to produce a XSD based on real data to compare with what they sent.

    Is this possible?

    I am able to query XML data using the tags that I see in data using XMLTable and it works fine.

    Any help is greatly appreciated.

    -gary

    Welcome to the side of the world, where you're going to love it and curse, like any other piece of XML technology.

    So if I understand correctly, the scope of your operation is to extract information from an XML file and then write this information to the disk, correct?

    A few questions

    -Why did the XML stored in a CLOB instead of an XMLType column?  Without knowing the history of the system, it is a pertinent question.

    -What size are the XML?  I ask this question, it is because when the XML is stored in the columns of XMLType (relational structure object or XML BINARY SECUREFILE format), then Oracle can parse the XML much more easily when it is stored as a CLOB.  If the XML is small enough, you can see no difference in performance between the two.

    The Oracle DB itself has no built in the ability to generate a schema from an XML file.  To do this, you need to use a third-party tool that has this feature in.  For example, XML Spy can do.  Other tools as well, but that's what comes to mind first is what I use.  The only thing to remember is that the scheme he built is only an XML instance.  Other XML instances can be different and not valid against the schema you generated, but still valid against the original schema unknown.

    You can save the schema in the database and then use the XML to create an XMLType instance related to the schema and then validate the XML in this way.  An example XML DB FAQ and here's another one Re: validation of XML schema

    Hope that helps you continue.

  • Loading XML data in ListView of C++ after extraction of http data

    I'm sorry did searh but could not find any refrence related to my problem
    I am trying to load the xml data returned from a web service HTTP Post QNetworkRequest and QNetworkReply in c ++.

    My XML that gets donwloaded is as

    
     http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">
      
        tu7652
        F
        Marry
        Wijaya
      
      
        23
        F
        Marry
        Wijaya
      
    
    

    In My QML, it comes to the ListView can say SearchResult.qml

    ListView {
              objectName: "resultlist"
              dataModel: feedsdatamodel
              listItemComponents: [
                ListItemComponent {
                            type: "item"
                            PeopleListItem {
                                name: ListItemData.givenName + ", " + ListItemData.sn
                                role: ListItemData.ExtFunction
                                leftPaddingText: 40
                            }
                        }
               ]
            }
     attachedObjects: [
           // The data model that contains the content of a XML file
            GroupDataModel {
                id: feedsDataModel
                sortingKeys: [
                    "givenName"
                ]
                grouping: ItemGrouping.None
            }
        ]
    

    PeopleListItem.qml

    import bb.cascades 1.0
    
    Container {
        property alias name: titleLabel.text
        property alias role: functionLabel.text
        property alias leftPaddingText: textcontainer.leftPadding
    
        layout: StackLayout {
            orientation: LayoutOrientation.TopToBottom
        }
        preferredWidth: 768
        preferredHeight: 135
        Container {
    
            id: textcontainer
            topPadding: 10
    
            layout: StackLayout {
                orientation: LayoutOrientation.TopToBottom
            }
            Label {
    
                id: titleLabel
                textStyle.base: SystemDefaults.TextStyles.TitleText
                textStyle.color: Color.Black
            }
            Label {
                id: functionLabel
                textStyle.base: SystemDefaults.TextStyles.BodyText
                textStyle.color: Color.Gray
            }
        }
        Divider {
            verticalAlignment: VerticalAlignment.Bottom
        }
    }
    

    This is the function I'm using to display the QML it is called from main.qml and works correctly.

    void PeopleFinder::onSearchClicked() {
        qDebug() << "PeopleFinder::PeopleFinder::onSearchClicked::\t" << "begin";
        qDebug() << "PeopleFinder::PeopleFinder::onSearchClicked::\tfname:"
                << m_fname << "\tlname:" << m_lname;
    
        // Create a network access manager and connect a custom slot to its
        // finished signal
        mNetworkAccessManager = new QNetworkAccessManager(this);
    
        // create a data model with sorting keys for lastname and firstname
        Q_ASSERT(
                connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*))));
    
        //Load the bew QML file of Search from here
        QmlDocument *qml = QmlDocument::create("asset:///SearchResults.qml").parent(
                this);
        qml->setContextProperty("peoplefinder", this);
    
        Page *mypage = qml->createRootObject();
        qml->setParent(mypage);
        qDebug() << "PeopleFinder::PeopleFinder::onSearchClicked::\t s444444";
    
        // Retrieve the activity indicator from QML so that we can start
        // and stop it from C++
    //  mActivityIndicator = mypage->findChild("myIndicator");
    
        // Retrieve the list so we can set the data model on it once
        // we retrieve it
        mListView = mypage->findChild("resultlist");
    
        mNavigator->push(mypage);
    }
    

    Once the page loads in the QML it call the launch request providing c ++ file and once the
    query is completed under function is called with the data. I checked that data are downloaded properly

    void PeopleFinder::requestFinished(QNetworkReply* reply) {
        qDebug() << "PeopleFinder::PeopleFinder::requestFinished::\t"
                << "response received";
        // Check the network reply for errors
        if (reply->error() == QNetworkReply::NoError) {
    
            // Open the file and print an error if the file cannot be opened
            qDebug() << "PeopleFinder::PeopleFinder::requestFinished::\t"
                    << "No error";
    
            // Write to the file using the reply data and close the file
            QByteArray xml = reply->readAll();
            qDebug() << "Data: \n" << xml;
    
            // load the xml data
            XmlDataAccess xda;
            QVariant list = xda.load(xml, "ArrayOfPeople");
    
            qDebug() << "List:::\n" << list;
    
            GroupDataModel *datamodel = (GroupDataModel*)mListView->dataModel();
            // add the data to the model
            datamodel->clear();
            datamodel->insertList(list.value());
            datamodel->setSortingKeys(QStringList() << "givenName" << "sn");
            qDebug() << "PeopleFinder::PeopleFinder::requestFinished::\t"
                    << "Datamodel set size:: " << datamodel->size();
    
            // Set the new data model on the list and stop the activity indicator
    
        } else {
            qDebug() << "\n Problem with the network";
            qDebug() << "\n" << reply->errorString();
        }
    }
    

    But now, the real problem begins as in how to convert QByteArray data type of QVariantList which can be loaded into the datamodel
    I don't want to write the data to the XML file and then pass that as a list his will is very slow, once I move test environment to the production environment.

    Please help me solve this problem

    I got it to work using xml parsing with QXmlStreamReader

  • extract data from blob field containing xml data big

    I'm working on Oracle 11 g 2, 11.0.2.0.3. UNIX database server.

    my oracle instance receive large xml data service web ftp, I put this file as blob in a table called TBL_ALERT_XML (ID_ALERT NUMBER, DATE of the TIMESTAMP_ALERT, ALERT_XML BLOB).

    My goal is to get data of BLOB content e file put in one or more other tables.

    I try with the opening of a cursor on

    SELECT XMLTYPE (UTL_RAW.cast_to_varchar2 (ALERT_XML)). Extract (' alerts/points/point / / Text () ') threads

    OF TBL_ALERT_XML

    without any filter on ID_ALERT.

    But I get the error:

    ORA-22835: buffer too small for to CHAR CLOB or BLOB to RAW conversion



    Please help me, thank you very much

    Because the web service is deployed in python and my co worker is not able to call a stored procedure with the parameter xmltype, but only with the setting of the BLOB.

    If you can't get around it, so be it. All the less, using CLOB would be better.

    However, which prevents you to convert BLOB XMLType entry within the stored procedure and store it in an XMLType column.

    To do this, simply use the XMLType of BLOB.

    create table tbl_alert_xml)

    number of id_alert

    date of timestamp_alert

    alert_xml xmltype

    );

    insert into tbl_alert_xml

    values)

    1

    sysdate

    xmltype (p_blob

    , nls_charset_id ('AL32UTF8') - put the encoding of the file here

    )

    );

    Then, you will be able to execute queries optimized using XMLTABLE.

  • Extraction of XML data and display new line

    I have a table named, SAPDATABROWSER, which has several columns and lines. A column named SAPTEXT (data type: CLOB) consist of xml data. Each XML data are different in terms of number of nodes, but has the same following structure:

    < SAP_BAPI_PROP >
    < SelectedProperty >
    < structure >
    < field > < / field >
    < length > < / length >
    < FieldValue > < / FieldValue >
    < type > < / Type >
    < priority > < / priority >
    < / structure >
    < / SelectedProperty >
    < / SAP_BAPI_PROP >

    So now, what I would do is, to extract the values: field, FieldValue and the length of each line (total 72) and see the result as follows.

    Length of track FieldValue
    XXXX YYYY ZZZZ
    PPPP QQQQ RRRR
    AAAA BBBB CCCC
    MMMM OOOO NNNN

    Again, each line (total 72) has several XML Data nodes, IE there are several nodes FieldType, length and field and no two XML data/line are similar!

    I use the following code:

    SELECT
    EXTRACT (xmltype (saptext), ' / SAP_BAPI_PROP/SelectedProperty/Structure/Field / text () ');
    EXTRACT (xmltype (saptext), ' / SAP_BAPI_PROP/SelectedProperty/Structure/Length / text () ');
    EXTRACT (xmltype (saptext), ' / SAP_BAPI_PROP/SelectedProperty/Structure/FieldValue / text () ')
    OF sapdatabrowser;

    The code above produces the following result:

    SAP_BAPI_PROP/.../Field/Text () SAP_BAPI_PROP/.../Length/text () SAP_BAPI_PROP/.../FieldValue/text)
    1 XXXXPPPPAAAA YYYYQQQQBBBB ZZZZRRRRCCCC
    2 MMMM OOOO NNNN


    Any suggestions? Thank you very much. :)

    Based on your sample data:

    SQL> select x.*
      2  from sapdatabrowser t
      3     , xmltable(
      4         '/SAP_BAPI_PROP/SelectedProperty/Structure'
      5         passing xmltype(t.saptext)
      6         columns field_name  varchar2(30) path 'Field'
      7               , field_len   varchar2(30) path 'Length'
      8               , field_val   varchar2(30) path 'FieldValue'
      9       ) x
     10  ;
    
    FIELD_NAME                     FIELD_LEN                      FIELD_VAL
    ------------------------------ ------------------------------ ------------------------------
    X                              Y                              Z
    P                              Q                              R
    A                              B                              C
    M                              N                              O
     
    

    (adjust the projected if necessary data types)

  • Extract XML with xmlns duble truble, 9i database data

    Hello

    I have a problem extracting the data from the example:

    My xml file:
    <? XML version = "1.0" encoding = "UTF-8"? >
    < document xmlns = "http://www.crea.si/Schemas/2004/Document/ZbsXml" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://www.crea.si/Schemas/2004/Document/ZbsXml ZbsCreaDoc.xsd" >
    < data >
    < DataFormat >
    text/xml, < MimeType > < / MimeType >
    < / DataFormat >
    < content >
    < EmbeddedData >
    < Paket xmlns = "http://www.zbs-giz.si/Schemas/2006/ZbsXml" >
    < VodilniZapis >
    < StevilkaRacuna > 00000000 < / StevilkaRacuna >
    < StevilkaPaketa > 0000 < / StevilkaPaketa >
    < DatumPaketa > 0000 - 00 - 00 < / DatumPaketa >
    < / VodilniZapis >
    < / Paket >
    < / EmbeddedData >
    < / content >
    < / data >
    < / document >

    my selection:
    SELECT extractValue (Value (t), ' VodilniZapis/StevilkaPaketa', 'xmlns = "http://www.crea.si/Schemas/2004/Document/ZbsXml" ') MimeType
    TABLE (XMLSequence (extract (xm, ' / Document/data/content/EmbeddedData/package/VodilniZapis ',' xmlns = "http://www.crea.si/Schemas/2004/Document/ZbsXml" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" '))) t;

    It does not work except that it I use only one < package > instead of < Paket xmlns = "http://www.zbs-giz.si/Schemas/2006/ZbsXml" >


    Anyopne help me? Thank you.

    Hello

    Since the element child "Paket" comes from another namespace, you must qualify (and its descendants) in the XPath expression.

    Something like this should do it:

    SELECT extractValue(value(t), 'VodilniZapis/StevilkaPaketa', 'xmlns="http://www.zbs-giz.si/Schemas/2006/ZbsXml"') mimetype
    FROM TABLE(
      XMLSequence(
        extract( xml, '/Document/Data/Content/EmbeddedData/ns2:Paket/ns2:VodilniZapis',
                 'xmlns="http://www.crea.si/Schemas/2004/Document/ZbsXml",
                  xmlns:ns2="http://www.zbs-giz.si/Schemas/2006/ZbsXml"' )
      )
    ) t;
    
  • How to extract an XML data that have different namespace prefixes?

    Hello

    I have inserted XMLs in an XMLTYPE column which are based on a common XSD that allows different namespaces.

    How can I extract some data from these XMLs using extractvalue when will be preceded different namespaces for this node?

    Thank you and best regards,
    A

    Hello

    You can use XPath:

    //*[local-name()="node_name"]
    

    For example:

    with t as (
     select xmltype(
     '
      mark
      del
     '
     ) doc
     from dual union all
     select xmltype(
     '
      john
      mum
     '
     )
     from dual
    )
    select extractvalue(t.doc,'//*[local-name()="name"]') as name,
           extractvalue(t.doc,'//*[local-name()="place"]') as place
    from t;
    

    or,

    with t as (
     select xmltype(
     '
      mark
      del
     '
     ) doc
     from dual union all
     select xmltype(
     '
      john
      mum
     '
     )
     from dual
    )
    select x.*
    from t, XMLTable(
    '
     {
      element name { //*[local-name()="name"] },
      element place { //*[local-name()="place"] }
     }
     '
    passing t.doc
    columns
     place varchar2(30) path 'place',
     name  varchar2(30) path 'name'
    ) x;
    

Maybe you are looking for