Extracting data from an XML document that uses namespaces
Hello all,
Firstly, please let me wish you all a very happy and prosperous 2013!
I have a piece of XML containing namespaces (retrieved from a web service) and I am having difficulty extracting values
(If you're interested this is the webservice: http://api.worldbank.org/countries/FRA/indicators/NY.GDP.MKTP.CD?date=2009)
Here is some test code with two cases -
1) where I leave in the namespace and
2) where I strip out all references to the namespace
Case 1 doesn't work, whereas Case 2 works well.
I would prefer a more elegant solution than simply stripping out the namespace.
I have probably just misunderstood something about how to work with namespaces in PL/SQL.
Do any of you have suggestions about how best to approach this?
Many thanks in advance.
Niall.
set serveroutput on
set define off
DECLARE
v_xml XMLTYPE;
v_clob CLOB;
v_country VARCHAR2(255);
BEGIN
v_clob := '<?xml version="1.0" encoding="utf-8"?>
<wb:data page="1" pages="1" per_page="50" total="1" xmlns:wb="http://www.worldbank.org">
<wb:data>
<wb:indicator id="NY.GDP.MKTP.CD">GDP (current US$)</wb:indicator>
<wb:country id="FR">France</wb:country>
<wb:date>2009</wb:date>
<wb:value>2619685000757.11</wb:value>
<wb:decimal>0</wb:decimal>
</wb:data>
</wb:data>';
v_xml := XMLTYPE(v_clob);
SELECT extractvalue(v_xml,'/data/data[1]/country', 'xmlns:"http://www.worldbank.org/"')
INTO v_country
FROM dual;
dbms_output.put_line(' ');
dbms_output.put_line('*** Case 1');
dbms_output.put_line('*** '||nvl(v_country,'nothing'));
dbms_output.put_line(v_xml.getStringVal());
v_xml := XMLTYPE(replace(v_clob,'wb:')); -- strip out wb:
SELECT extractvalue(v_xml,'/data/data[1]/country', 'xmlns:"http://www.worldbank.org/"')
INTO v_country
FROM dual;
dbms_output.put_line(' ');
dbms_output.put_line('*** Case 2');
dbms_output.put_line('*** '||nvl(v_country,'nothing'));
dbms_output.put_line(v_xml.getStringVal());
END;
/
Your case 1 query should be
(not tested)
SELECT extractvalue(v_xml,'/wb:data/wb:data[1]/wb:country', 'xmlns:wb="http://www.worldbank.org/"')If the XML is going to be small, you could also do it this way purely in PL/SQL
[url http://anononxml.blogspot.com/2010/06/xml-parsing-with-namespaces-via-plsql.html]XML Parsing with Namespaces via PL/SQL. Ignore the DOMDocument examples (first two) in there.
If the XML will be large and you are on 11.1 or greater, then it would be faster to insert the XML into a column in a DB table (could be a global temporary table) where the column is XMLType and the storage is SECUREFILE BINARY (default on 11.2.0.2+). Then you could use XMLTable, like
[url http://anononxml.blogspot.com/2010/08/xml-parsing-with-namespaces-via.html]XML Parsing with Namespaces via XMLTable
Similar Messages
-
When I extracting data from DSO to Cube by using DTP.
When i am extracting data from DSO to Cube by using DTP.
I am getting following erros.
Data package processing terminated (Message no. RSBK229).
Error in BW: error getting datapakid cob_pro (Message no. RS_EXCEPTION105).
Error while extracting from source 0FC_DS08 (type DataStore) - (Message no. RSBK242).
Data package processing terminated. (Message no. RSBK229).
Data package 1 / 10/04/2011 15:49:56 / Status 'Processed with Errors'. (Message no. RSBK257).
This is the brand new BI 7.3 system. Implementing the PSCD and TRM.
I have used the standard business content objects in FI-CA (dunning history header, item,activities) and standard Datasource (0FC_DUN_HEADER ,0FC_DUN_ITEMS, 0FC_DUN_ACTIVITIES). I have extracted data till the DSO level . when I try to pull the data to info provider level(cube) using DTP . I am getting fallowing error.
my observation: when ever I use the DSO as source to any target like another DSO or cube. its throwing same kind of error for any flow including simple Flat file .
please suggest any one whether do I need to maintain basic settings since its a brand new BI 7.3.
please help me out on this issue . I am not able to move forward .its very urgenthello
Have you solved the problem ?
I have the same error...
as you solve this error,
can you help me please I have the same error
yimi castro garcia
[email protected] -
How to extract data from Essbase to Flat File using ODI
Hi,
Anyone know how to extract data from Essbase to Flat File using ODI?
Thanks in advance.
Regards,
SumardiHi,
Have you read through :-
Oracle Data Integrator Adapter for Hyperion Essbase Getting Started - http://download.oracle.com/docs/cd/E10530_01/doc/epm.931/odiess_getting_started.pdf
Oracle Data Integrator Adapter for Hyperion Essbase User's Guide - http://download.oracle.com/docs/cd/E10530_01/doc/epm.931/odiess_users.pdf
If you have read them and are still have a problem at what stage are you having the issues?
Cheers
John
http://john-goodwin.blogspot.com/ -
How to extract data from custom made Idoc that is not sent
Hi experts,
Could you please advise if there is a way how to extract data from custom made idoc (it collects a lot of data from different SAP tables)? Please note that this idoc is not sent as target system is not fully maintained.
As by now, we would like to verify - what data is extracted now.
Any help, would be appreciated!Hi,
The fields that are given for each segment have their length given in EDSAPPL table. How you have to map is explained in below example.
Suppose for segment1, EDSAPPL has 3 fields so below are entries
SEGMENT FIELDNAME LENGTH
SEGMENT1 FIELD1 4
SEGMENT1 FIELD2 2
SEGMENT1 FIELD3 2
Data in EDID4 would be as follows
IDOC SEGMENT APPLICATION DATA
12345 SEGMENT1 XYZ R Y
When you are extracting data from these tables into your internal table, mapping has to be as follows:
FIELD1 = APPLICATIONDATA+0(4) to read first 4 characters of this field, because the first 4 characters in this field would belong to FIELD1
Similarly,
FIELD2 = APPLICATIONDATA+4(2).
FIELD3 = APPLICATIONDATA+6(2).
FIELD1 would have XYZ, FIELD2 = R, FIELD3 = Y
This would remain true in all cases. So all you need to do is identify which fields you want to extract, and simply code as above to extract the data from this table.
Hope this was helpful in explaining how to derive the data. -
Problem extracting data from R/3 to BW using infopackage?
Hi all,
I am trying to extract data from R/3 to BI7.0 through infopackage and its giving below error.
Request still running
Diagnosis
No errors found. The current process has probably not finished yet.
System Response
The ALE inbox of BI is identical to the ALE outbox of the source system
or
the maximum wait time for this request has not yet been exceeded
or
the background job has not yet finished in the source system.
Current status
No Idocs arrived from the source system
In the details tab:
Extraction (messages): Missing messages in yellow status
Missing message: Request received
Missing message: Number of sent records
Missing message: Selection completed
Transfer (IDocs and TRFC): Missing messages or warnings in yellow status
Data Package 1 : arrived in BW ; Processing : Selected number does not agree with transferred n
Processing (data packet): Everything OK in green status
Data Package 1 ( 370 Records ) : Everything OK
Inbound Processing ( 370 Records ) : No errors
Data package 1 received; Processing is starting
Update PSA ( 370 Records posted ) : No errors
Data package 1 is being saved...
370 records for data package 1 updated successfully, 0 records filtered
Processing end : No errors
Inbound processing of data package 1 finished.
Please anyone try to look at this issue and give me better soluttion ASAP.
Thanks,
Suresh.Hi ,
The infopackage run for avery long time in yellow state with out changing to green, This might happen due to connection error(get in touch with your basis team) or due to over load on the system.
eventhough the status of request is finished in source system, the job will be executing in the BI.
1)Wait for sometime for the request to turn out green automatically or
2)make the request to red and delte, repeat the infopackage step.
3)IF you know about the no of records that need to be transferred and if the total records are transferred already, manually change the request to green.
Cheers,
Srinath -
Extracting data from sap to java application using JCO
Hi,
I am new to sap and wanted to know what is the procedure to extract data from based on the java application client (user defined input from different tables of sap) input and need to manage huge data meaning reading millions of records.kindly help me how to handle this in ABAP.Hi,
Pls chk these links
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ad09cd07-0a01-0010-93a9-933e247d3ba4
Accessing SAP Tables from a Java application
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/47b6cd90-0201-0010-5aba-b6b7474d4aff
Java Application ,SAP BW
<b>***Reward Points if Useful</b>
Regards
Gokul -
There is IMP utility which provides me data as graphical way. But i need extract data in such a way so that i could able to use in my application.
thanks,
mohanHi,
EdStevens
Actually I was using SQL Developer. Sorry for the wrong define question. Now the real problem is:
I want to read or extract data in a txt file from Oracle Dump (.dmp) file without using Oracle sqlPlus or Oracle Database.
No need to say that i am able to extract dump data using sqlPlus. But for that, there is a little burden to install oracle database
or sql Developer.
I also listen about Oracle Loader a little bit. Is it a tool for providing extraction of data from Oracle dump file.
Thanks for your previous reply,
And now waiting for your suggestion.
thanks,
mohan -
There is import which provides me data as graphical way. But i need extract data in such a way so that i could able to use in my application.
thanks,
mohanThis isn't a SQLDeveloper question. You will get better answers in the Database - General forum.
Oracle dump files produced by the exp or expdp utilities are inproprietary formats which can only be read by the imp or impdp utilities respectively.
The best way to get data out of a dump file is to import it into a database and then extract it to plain text files using SQL.
Alternatively, leave it in the database and your application can access it there.
The exp dump file is mostly plain text, but the format is not published so you could waste a lot of time figuring it out. -
How to extract Data from HR into BW by using the LSA Stamping Approach?
Hi All,
i have an issue regarding the extraction on Data fron HR into BW by using the LSA stamping approach.
Could some one give me some steps are the logi should be implemented? Or document?
Thank
You
Cheershi,
You can find the business content objects here:
http://help.sap.com/saphelp_nw04/helpdata/en/04/47a46e4e81ab4281bfb3bbd14825ca/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/3a/7aeb3cad744026e10000000a11405a/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/16/4d0b3c56488e6be10000000a114084/frameset.htm
For other info you can look up some OSS notes and forum threads (like for details on CRM extraction)
You can check out the best practices here:
http://help.sap.com/bp_biv170/html/bw.ht
Hope this helps you
regards
harikrishna N -
How can I extract data from ST03 - what tables are used?
Hi
I currently have to create performance statistics daily for management. To do this I use transaction ST03 and manually copy the previous days Dialog average response time, DB, CPU and GU av. times into a spreadsheet, and also the average dialog response time for 4 key transactions from the transaction profile.
It would be nice to automate this. I was thinking of writing a basic ABAP program to query the relevant tables to extract this data - does anyone know which tables are used? I'd tried running a trace but it was not clear which tables/rows etc would be required.
Thanks
RossOk, that FM is an old one - for NW2004s (700) need to use 'SWNC_COLLECTOR_GET_AGGREGATES'.
Have a basic program below. What I'm trying to do is get the average response time for transactions. I can get 'respti' from the table but I think this is the total response time - what field represents average response time?
Also, the numbers that it's pulling back don't seem to match the numbers in ST03 at all... except 'dcount'. This seems to correct ly show the number of steps... but the other values don't match anything. What am I doing wrong?
Program below...
Cheers
Ross
REPORT Z_GETSTATS.
PARAMETER: day TYPE dats DEFAULT sy-datum.
DATA: t_usertcode TYPE swnc_t_aggusertcode,
wa_usertcode TYPE swncaggusertcode.
START-OF-SELECTION.
CALL FUNCTION 'SWNC_COLLECTOR_GET_AGGREGATES'
EXPORTING
component = 'TOTAL'
periodtype = 'D'
periodstrt = day
TABLES
usertcode = t_usertcode
EXCEPTIONS
no_data_found = 1
OTHERS = 2.
LOOP AT t_usertcode INTO wa_usertcode.
WRITE:/ wa_usertcode-entry_id.
WRITE:/ wa_usertcode-respti, wa_usertcode-procti, wa_usertcode-cputi, wa_usertcode-dcount, wa_usertcode-ucount.
WRITE:/ '*************************************'.
ENDLOOP. -
Hi, extract data from xml file and insert into another exiting xml file
i am searching code to extract data from xml file and insert into another exiting xml file by a java program. I understood it is easy to extract data from a xml file, and how ever without creating another xml file. We want to insert the extracted data into another exiting xml file. Suggestions?
1st xml file which has two lines(text1.xml)
<?xml version="1.0" encoding="iso-8859-1"?>
<xs:PrintDataRequest xmlns:xs="http://com.unisys.com/Anid"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
<xs:Person>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
These two lines has to be inserted in the existing another xml(text 2.xml) file(at line 3 and 4)
Regards,
bubblyJadz_Core wrote:
RandomAccessFile? If you know where you want to insert it.Are you sure about this? If using this, the receiving file would have to have bytes inserted that exactly match the number of bytes replaced. I'm thinking that you'll likely have to stream through the second XML with a SAX parser and copy information (or insert new information) as you stream with an XML writer of some sort. -
Extract data from xml file and insert into another exiting xml fil
hello,
i am searching extract data from xml file and insert into another exiting xml file by a java program. I understood it is easy to extract data from a xml file, and how ever without creating another xml file. We want to insert the extracted data into another exiting xml file. Suggestions?
Regards,
ZhuozhiIf the files are small, you can load the target file in a DOM document, insert the data from the source file and persist the DOM.
If the files are large, you probably want to use a StAX or SAX. -
Extracting date from oracle/other databases exactly to java
Hello Friends,
Iam creating a simple program which extracts data from any database and stores it in an XML file and also it can extract data from an XML file and updates the database.
My program is just getting the tablename as an input and from that it builds the query (select * from tablename). Through ResultSet, Iam extracting date fields with getDate() method of ResultSet, which is yeilding converted dates [In oracle if date is 23-DEC-1980, Im getting it as 1980-12-23 in java]. Even getString() method of ResultSet doesn't work.
I want my program to work with any database engine, which may have their own date formats. Kindly can anyone suggest me a way to extract date from any database exactly as it is to java.
NOTE:: I can't use to_char(datefield) type commands in SQLQUERY as the only input to my program is tablename and my query is, select * from tablename.
Regards,
Ch.Praveen.HI Friends,
Thanks for your fast replies. My program is extracting data from a database and generating an XML file for it, which is as follows.
<?xml version="1.0" encoding="UTF-8"?>
<table tableName="EMP">
<row>
<column columnName="EMPNO" columnType="NUMBER">7369</column>
<column columnName="ENAME" columnType="VARCHAR2">'SMITH'</column>
<column columnName="JOB" columnType="VARCHAR2">'CLERK'</column>
<column columnName="MGR" columnType="NUMBER">7902</column>
<column columnName="HIREDATE" columnType="DATE">'1980-12-17'</column>
<column columnName="SAL" columnType="NUMBER">800</column>
<column columnName="COMM" columnType="NUMBER" />
<column columnName="DEPTNO" columnType="NUMBER">20</column>
</row>
<row>
<column columnName="EMPNO" columnType="NUMBER">7499</column>
<column columnName="ENAME" columnType="VARCHAR2">'ALLEN'</column>
<column columnName="JOB" columnType="VARCHAR2">'SALESMAN'</column>
<column columnName="MGR" columnType="NUMBER">7698</column>
<column columnName="HIREDATE" columnType="DATE">'1981-02-20'</column>
<column columnName="SAL" columnType="NUMBER">1600</column>
<column columnName="COMM" columnType="NUMBER">300</column>
<column columnName="DEPTNO" columnType="NUMBER">30</column>
</row>
</table>
Here you can observe that HIREDATE column is having date in different format than in oracle. We are getting an error while we are extracting data from an XML file and updating the database, as dateformats differ. Can anyone provide a solution, which extracts date from database to java exactly as per the dateformat in database. -
How can I extract data from a sound file in carbon
hello,
I am a student and I start recently learning carbon. I have to do a application which can read and extract data from a sound file and use that data to do some kind of visual representation of the file. I would like to know if someone can give some directions, tutorial,some code sample etc.
thank you for your help
chenita7hello orangekay
My idea is to create an application that can read a sound file( AIFF, MP3 or other) in order to extract some kind of data ( numbers or any values) and use that data to represent the sound file visually.
I dont know which kind of data can be extract from a sound file, and in which way i can manipulate that data to became a visual representation of the sound file. this is what I want to do as my second assignment for a subject at school, introduction to programming. has to be done based in carbon.
regards
chenita7 -
To extract Data from Pool Table Data Sources
hi
I want to extract data from Pool table, for that i want to create infoset for that pool table. can anyone please let me know the
procedure to create info set on pool tables.
Regards
Atul
Moderator message: please (re)search yourself first.
Edited by: Thomas Zloch on Nov 8, 2010 12:54 PMHi Atul
You have a couple of options here:
1) Create Infoset SQ02 on those tables and RSO2 - create generic ds
2) Create functional Module and create generic ds using FM
Replicate DS to BW and Build objects and map them in transformations and create dtp and IP.
Refer to this [link|How to extract data from a pool table?; for more details.
Regards
Harsh
Maybe you are looking for
-
Editing text in Dreamweaver CS4 on Mac 10.6.2 causes paragraph ends to disapear
Editing text in Dreamweaver CS4 on Mac 10.6.2 causes paragraph ends to disappear. When adding bold in design view (strong) to two words at the start of my paragraph the last line of the paragraph disappears. This is somewhat worrying as it means any
-
SF300-24 is not saving configuration after reboot
Dear All, I have a couple of SF300-24 switches. When I made needed configurations using CLI or GUI and then saved all configurations. The problem is that switches do not save configurations after reboot. Please assist. Thank you in advance
-
How do I turn on the sync on my 8330?
-
Premiere Pro 5.5.2 crashes on opening existing project
ok so i haven't had an issue before. but its been a few months since i last used premiere pro. so i open premiere pro and i create a new project, i add my music and the mp4's i will be using, i'm on a mac osx by the way most recent version, so im abl
-
Is it possible to set a QueueReceiver or a MessageDrivenBean to collect messages from more than one queue? And how? eg. I have 3 queues q1: IncomingCars q2: IncomingVans q3: IncomingTrucks and I have only RepairMessageDrivenBean which onMessage() sho