How to extract a single colum form XML files and load in a table
Hi below I have a structure of xml files , I just need to extarct <RecordReference>PQPMID:7358</RecordReference>
from file and load in to oracle ..
Please let me know how to do ..??
file content below
HoldingsRecord>
<RecordReference>PQPMID:7358</RecordReference>
<NotificationType>00</NotificationType>
<SerialVersion>
<SerialVersionIdentifier>
<SerialVersionIDType>07</SerialVersionIDType>
<IDValue>1068624X</IDValue>
</SerialVersionIdentifier>
<SerialVersionIdentifier>
<SerialVersionIDType>01</SerialVersionIDType>
<IDTypeName>PMID</IDTypeName>
<IDValue>7358</IDValue>
</SerialVersionIdentifier>
<Title>
<TitleType>02</TitleType>
<TitleText>Pittsburgh Post - Gazette</TitleText>
</Title>
<Publisher>
<PublishingRole>01</PublishingRole>
<PublisherName>Post Gazette Publishing Company</PublisherName>
</Publisher>
<OnlinePackage>
<OnlineServiceName>ProQuest</OnlineServiceName>
<Website>
<WebsiteRole>03</WebsiteRole>
<WebsiteLink>http://proquest.umi.com/pqdweb</WebsiteLink>
</Website>
<HoldingsDetail>
<JournalIssue>
<JournalIssueRole>04</JournalIssueRole>
<JournalIssueDate>
<DateFormat>00</DateFormat>
<Date>19930118</Date>
</JournalIssueDate>
</JournalIssue>
<JournalIssue>
<JournalIssueRole>06</JournalIssueRole>
<JournalIssueDate>
<DateFormat>00</DateFormat>
<Date>20080915</Date>
</JournalIssueDate>
</JournalIssue>
<EpubFormat>10</EpubFormat>
</HoldingsDetail>
</OnlinePackage>
</SerialVersion>
</HoldingsRecord>
DECLARE
l_clob CLOB;
l_bfile BFILE;
l_parser dbms_xmlparser.Parser;
l_doc dbms_xmldom.DOMDocument;
l_nl dbms_xmldom.DOMNodeList;
l_n dbms_xmldom.DOMNode;
l_temp VARCHAR2(1000);
src_csid NUMBER := NLS_CHARSET_ID('UTF8');
dest_offset INTEGER := 1;
src_offset INTEGER := 1;
lang_context INTEGER := dbms_lob.default_lang_ctx;
warning INTEGER;
TYPE tab_type IS TABLE OF gt_pq_pmid%ROWTYPE;
t_tab tab_type := tab_type();
BEGIN
l_bfile := BFileName('XML_DIR', 'SOH_sample.xml');
dbms_lob.createtemporary(l_clob, cache=>FALSE);
dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
dbms_lob.loadclobfromFile( l_clob,
l_bfile,
dbms_lob.getLength(l_bfile),
dest_offset,
src_offset,
src_csid,
lang_context,
warning);
dbms_lob.close(l_bfile);
dbms_session.set_nls('NLS_DATE_FORMAT','''DD-MON-YYYY''');
l_parser := dbms_xmlparser.newParser;
dbms_xmlparser.parseClob(l_parser, l_clob);
l_doc := dbms_xmlparser.getDocument(l_parser);
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
-- Get a list of all the row nodes in the document using the XPATH syntax.
l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'HoldingsRecord/');
FOR cur_stage_xml IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
l_n := dbms_xmldom.item(l_nl, cur_stage_xml);
t_tab.extend;
dbms_xslprocessor.valueOf(l_n,'RecordReference/text()',t_tab(t_tab.last).pq_pmid);
END LOOP;
FOR cur_stage_xml IN t_tab.first .. t_tab.last LOOP
INSERT INTO
gt_pq_pmid (
pq_pmid )
VALUES
(t_tab(cur_stage_xml).pq_pmid);
END LOOP;
COMMIT;
dbms_xmldom.freeDocument(l_doc);
EXCEPTION
WHEN OTHERS THEN
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
dbms_xmldom.freeDocument(l_doc);
raise ;
END;---------- and i am getting below error
ERROR at line 1:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00210: expected '<' instead of 'H'
Error at line 1
ORA-06512: at line 65
Similar Messages
-
How to extract data from an arbitrary xml file and export in a nice csv file?
Hallo,
I'm facing big problems in the use of XML files. I have an
application which generates XML files with clusters containing arrays
and scalars like in the example pasted below. My task is to
read it and export the data in a human-friendly CSV document.
Since I don't know the actual content of the cluster, I need some kind
of intelligent vi which goes through the XML file looking for arrays
and other data structures in order to export them properly in the CSV
format (columns with headers).
Thank you
<Cluster>
<Name></Name>
<NumElts>3</NumElts>
<Array>
<Name></Name>
<Dimsize>6</Dimsize>
<I32>
<Name></Name>
<Val>0</Val>
</I32>
<I32>
<Name></Name>
<Val>1</Val>
</I32>
<I32>
<Name></Name>
<Val>2</Val>
</I32>
<I32>
<Name></Name>
<Val>3</Val>
</I32>
<I32>
<Name></Name>
<Val>4</Val>
</I32>
<I32>
<Name></Name>
<Val>5</Val>
</I32>
</Array>
<DBL>
<Name></Name>
<Val>3.14159265358979</Val>
</DBL>
<String>
<Name></Name>
<Val>ciao</Val>
</String>
</Cluster>
Solved!
Go to Solution.Thank you again,
I'm forwarding my vi draft with many comments and an xml file sample.
Data in cluster is stored according to the LabVIEW schema, infact it is generated by LabVIEW.
What I'm trying to do is to access the element of the cluster and read their content using the Invoke node and Property node functions. Could you give it a look, there may be something wrong, I'm not able to access cluster children.
Which funcions should I use? Could you give me an example? You may use the draft I enclosed...
Then write these data in a csv file
should be the easier part.
BODY{font:x-small 'Verdana';margin-right:1.5em}
.c{cursor:hand}
.b{color:red;font-family:'Courier New';font-weight:bold;text-decoration:none}
.e{margin-left:1em;text-indent:-1em;margin-right:1em}
.k{margin-left:1em;text-indent:-1em;margin-right:1em}
.t{color:#990000}
.xt{color:#990099}
.ns{color:red}
.dt{color:green}
.m{color:blue}
.tx{font-weight:bold}
.db{text-indent:0px;margin-left:1em;margin-top:0px;margin-bottom:0px;padding-left:.3em;border-left:1px solid #CCCCCC;font:small Courier}
.di{font:small Courier}
.d{color:blue}
.pi{color:blue}
.cb{text-indent:0px;margin-left:1em;margin-top:0px;margin-bottom:0px;padding-left:.3em;font:small Courier;color:#888888}
.ci{font:small Courier;color:#888888}
PRE{margin:0px;display:inline}
<?xml
version="1.0" encoding="iso-8859-1" ?>
<Contents type="Data"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="XMLSection.xsd">
<section name="beta"
date="7/31/2009" time="3:43:03 PM" version="1.0">
<Cluster>
<Name />
<NumElts>1</NumElts>
<Array>
<Name />
<Dimsize>4</Dimsize>
<DBL>
<Name>number: 0 to 1</Name>
<Val>0.93317638164326</Val>
</DBL>
<DBL>
<Name>number: 0 to 1</Name>
<Val>0.79233924020314</Val>
</DBL>
<DBL>
<Name>number: 0 to 1</Name>
<Val>0.39199947274518</Val>
</DBL>
<DBL>
<Name>number: 0 to 1</Name>
<Val>0.74817197429441</Val>
</DBL>
</Array>
</Cluster>
</section>
</Contents>
Attachments:
read_array.vi 12 KB -
Please recommend if we have options to read xml file and insert data into table without a temporary table.
DECLARE @data XML;
SET @data =N'<Root>
<List RecordID="946236" />
<List RecordID="946237" />
<List RecordID="946238" />
<List RecordID="946239" />
<List RecordID="946240" />
</Root>'
INSERT INTO t (id) SELECT T.customer.value('@RecordID', 'INT') AS id
FROM @data.nodes('Root/List')
AS T(customer);
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How to extract a single column from XML and load in Oracle
Hi
below I have a structure of xml files , I just need to extarct <RecordReference>PQPMID:7358</RecordReference>
from file and load in to oracle ..
Please let me know how to do ..??
file content below
HoldingsRecord>
<RecordReference>PQPMID:7358</RecordReference>
<NotificationType>00</NotificationType>
<SerialVersion>
<SerialVersionIdentifier>
<SerialVersionIDType>07</SerialVersionIDType>
<IDValue>1068624X</IDValue>
</SerialVersionIdentifier>
<SerialVersionIdentifier>
<SerialVersionIDType>01</SerialVersionIDType>
<IDTypeName>PMID</IDTypeName>
<IDValue>7358</IDValue>
</SerialVersionIdentifier>
<Title>
<TitleType>02</TitleType>
<TitleText>Pittsburgh Post - Gazette</TitleText>
</Title>
<Publisher>
<PublishingRole>01</PublishingRole>
<PublisherName>Post Gazette Publishing Company</PublisherName>
</Publisher>
<OnlinePackage>
<OnlineServiceName>ProQuest</OnlineServiceName>
<Website>
<WebsiteRole>03</WebsiteRole>
<WebsiteLink>http://proquest.umi.com/pqdweb</WebsiteLink>
</Website>
<HoldingsDetail>
<JournalIssue>
<JournalIssueRole>04</JournalIssueRole>
<JournalIssueDate>
<DateFormat>00</DateFormat>
<Date>19930118</Date>
</JournalIssueDate>
</JournalIssue>
<JournalIssue>
<JournalIssueRole>06</JournalIssueRole>
<JournalIssueDate>
<DateFormat>00</DateFormat>
<Date>20080915</Date>
</JournalIssueDate>
</JournalIssue>
<EpubFormat>10</EpubFormat>
</HoldingsDetail>
</OnlinePackage>
</SerialVersion>
</HoldingsRecord>My mistake - thought you're looking for a general idea. Here's the working example:
CREATE OR REPLACE PROCEDURE import_test (i_result_file IN XMLTYPE DEFAULT XMLTYPE(bfilename('XMLDIR','my_test.xml'),nls_charset_id('ALT32UTF8')))
IS
xml_rec XMLTYPE;
v_index PLS_INTEGER;
v_rec_ref VARCHAR2(30);
BEGIN
v_index := 1;
WHILE i_result_file.Existsnode('/rec/HoldingsRecord['||To_Char(v_index)||']') > 0
LOOP
BEGIN
--- Get the line
xml_rec := i_result_file.Extract('/rec/HoldingsRecord['||To_Char(v_index)||']');
CASE WHEN i_result_file.Existsnode('rec/HoldingsRecord['||To_Char(v_index)||']/RecordReference') > 0
THEN v_rec_ref := xml_rec.extract('HoldingsRecord/RecordReference/text()').getStringVal();
DBMS_OUTPUT.put_line('v_rec_ref: '||v_rec_ref);
END CASE;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.put_line('My Message: '||v_index||' '||SQLERRM);
END;
v_index := v_index + 1;
END LOOP;
END import_test;
and here is my_test.xml I have used:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<rec>
<HoldingsRecord>
<RecordReference>PQPMID:7358</RecordReference>
<NotificationType>00</NotificationType>
<SerialVersion>
<SerialVersionIdentifier>
<SerialVersionIDType>07</SerialVersionIDType>
<IDValue>1068624X</IDValue>
</SerialVersionIdentifier>
<SerialVersionIdentifier>
<SerialVersionIDType>01</SerialVersionIDType>
<IDTypeName>PMID</IDTypeName>
<IDValue>7358</IDValue>
</SerialVersionIdentifier>
<Title>
<TitleType>02</TitleType>
<TitleText>Pittsburgh Post - Gazette</TitleText>
</Title>
<Publisher>
<PublishingRole>01</PublishingRole>
<PublisherName>Post Gazette Publishing Company</PublisherName>
</Publisher>
<OnlinePackage>
<OnlineServiceName>ProQuest</OnlineServiceName>
<Website>
<WebsiteRole>03</WebsiteRole>
<WebsiteLink>http://proquest.umi.com/pqdweb</WebsiteLink>
</Website>
<HoldingsDetail>
<JournalIssue>
<JournalIssueRole>04</JournalIssueRole>
<JournalIssueDate>
<DateFormat>00</DateFormat>
<Date>19930118</Date>
</JournalIssueDate>
</JournalIssue>
<JournalIssue>
<JournalIssueRole>06</JournalIssueRole>
<JournalIssueDate>
<DateFormat>00</DateFormat>
<Date>20080915</Date>
</JournalIssueDate>
</JournalIssue>
<EpubFormat>10</EpubFormat>
</HoldingsDetail>
</OnlinePackage>
</SerialVersion>
</HoldingsRecord>
<HoldingsRecord>
<RecordReference>PQPMID:9875</RecordReference>
<NotificationType>00</NotificationType>
<SerialVersion>
<SerialVersionIdentifier>
<SerialVersionIDType>07</SerialVersionIDType>
<IDValue>1068624X</IDValue>
</SerialVersionIdentifier>
<SerialVersionIdentifier>
<SerialVersionIDType>01</SerialVersionIDType>
<IDTypeName>PMID</IDTypeName>
<IDValue>7358</IDValue>
</SerialVersionIdentifier>
<Title>
<TitleType>02</TitleType>
<TitleText>Pittsburgh Post - Gazette</TitleText>
</Title>
<Publisher>
<PublishingRole>01</PublishingRole>
<PublisherName>Post Gazette Publishing Company</PublisherName>
</Publisher>
<OnlinePackage>
<OnlineServiceName>ProQuest</OnlineServiceName>
<Website>
<WebsiteRole>03</WebsiteRole>
<WebsiteLink>http://proquest.umi.com/pqdweb</WebsiteLink>
</Website>
<HoldingsDetail>
<JournalIssue>
<JournalIssueRole>04</JournalIssueRole>
<JournalIssueDate>
<DateFormat>00</DateFormat>
<Date>19930118</Date>
</JournalIssueDate>
</JournalIssue>
<JournalIssue>
<JournalIssueRole>06</JournalIssueRole>
<JournalIssueDate>
<DateFormat>00</DateFormat>
<Date>20080915</Date>
</JournalIssueDate>
</JournalIssue>
<EpubFormat>10</EpubFormat>
</HoldingsDetail>
</OnlinePackage>
</SerialVersion>
</HoldingsRecord>
</rec> -
How to parse SOAP XML output and load to oracle9i table
Below is the SOAP output response and I need to load the data into oracle 9i database tables.
I am able to parse regular XML without namespaces but unable to parse the data with namespaces.
I would need help in parsing this XML.
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>2011-11-04T23:16:08.437Z</u:Created>
<u:Expires>2011-11-04T23:21:08.437Z</u:Expires>
</u:Timestamp>
</o:Security>
</s:Header>
<s:Body>
<AssetGetListResponse xmlns="http://dev.services.xerox.com">
<AssetGetListResult xmlns:a="http://schemas.datacontract.org/2004/07/Xerox.MPS" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:AssetFeed>
<a:AccountID>de5862bf-f223-e011-bd3b-0024e861b15c</a:AccountID>
<a:AccountName>MPS-API Sandbox</a:AccountName>
<a:AssetID>ecf1545a-f1e9-e011-8a8a-0024e861b15c</a:AssetID>
<a:AssetNumber>57119B28</a:AssetNumber>
<a:AssetTag3rdParty i:nil="true"/>
<a:ChargebackCodeID>1a5962bf-f223-e011-bd3b-0024e861b15c</a:ChargebackCodeID>
<a:ContractNumber i:nil="true"/>
<a:ContractTypeDescription i:nil="true"/>
<a:ControlID i:nil="true"/>
<a:Group i:nil="true"/>
<a:GroupID i:nil="true"/>
<a:InScope>false</a:InScope>
<a:MACAddress>0000AA713E97</a:MACAddress>
<a:Manufacturer>Xerox</a:Manufacturer>
<a:Model>WorkCentre Pro 265</a:Model>
<a:ModifiedDate>2011-11-02T16:52:12.947Z</a:ModifiedDate>
<a:PricePlanID>c25a62bf-f223-e011-bd3b-0024e861b15c</a:PricePlanID>
<a:SerialNumber>UTU101993N</a:SerialNumber>
<a:VersionNumber>634558495329470000</a:VersionNumber>
</a:AssetFeed>
<a:AssetFeed>
<a:AccountID>de5862bf-f223-e011-bd3b-0024e861b15c</a:AccountID>
<a:AccountName>MPS-API Sandbox</a:AccountName>
<a:AssetID>b33b5160-f1e9-e011-8a8a-0024e861b15c</a:AssetID>
<a:AssetNumber>7EE42ADC</a:AssetNumber>
<a:AssetTag3rdParty i:nil="true"/>
<a:ChargebackCodeID>1a5962bf-f223-e011-bd3b-0024e861b15c</a:ChargebackCodeID>
<a:ContractNumber i:nil="true"/>
<a:ContractTypeDescription i:nil="true"/>
<a:ControlID i:nil="true"/>
<a:Group i:nil="true"/>
<a:GroupID i:nil="true"/>
<a:InScope>false</a:InScope>
<a:MACAddress>0800379B4C2A</a:MACAddress>
<a:Manufacturer>Xerox</a:Manufacturer>
<a:Model>WorkCentre 7428</a:Model>
<a:ModifiedDate>2011-11-02T16:52:14.383Z</a:ModifiedDate>
<a:PricePlanID>c25a62bf-f223-e011-bd3b-0024e861b15c</a:PricePlanID>
<a:SerialNumber>PBB015012</a:SerialNumber>
<a:VersionNumber>634558495343830000</a:VersionNumber>
</a:AssetFeed>
</AssetGetListResult>
</AssetGetListResponse>
</s:Body>
</s:Envelope>
This is what I tried.
declare
lp_parser xmlParser.Parser;
lx_xmldoc xmlDom.DOMDocument;
ln_doc_node xmlDom.DOMNode;
lnl_product xmlDom.DOMNodeList;
lnl_meter xmlDom.DOMNodeList;
ln_product xmlDom.DOMNode;
ln_meter xmlDom.DOMNode;
li_product_cnt NUMBER;
li_product_max NUMBER;
li_meter_cnt NUMBER;
li_meter_max NUMBER;
lnl_asset_meter_nodes xmldom.DOMNodeList;
ln_asset_meter_node xmldom.DOMNode;
ls_batch_number VARCHAR2(30);
ldt_proc_dt DATE;
ls_batch_item VARCHAR2(30);
ls_place_id place.place_id%TYPE;
ls_product_id product.product_id%TYPE := ' ';
ls_contract_id contract.contract_id%TYPE;
li_contract_version contract.contract_version%TYPE;
li_contract_sequence contr_product.sequence%TYPE;
ls_meter_id meter_log.meter_id%TYPE;
ls_read_type meter_log.read_type%TYPE;
ldt_reading_dt meter_log.reading_dt%TYPE;
li_meter_value meter_log.meter_value%TYPE;
li_adjust_copies meter_log.meter_value%TYPE;
ls_meter_type VARCHAR2(20);
ls_serial_id product.serial_id%TYPE;
ls_meter_read_type VARCHAR2(50);
invalid_parsing EXCEPTION;
PRAGMA EXCEPTION_INIT(invalid_parsing, -20100);
BEGIN
FOR meter_xml_rec IN (SELECT SOAP_RESPONSE
FROM temp_table
WHERE call_id=2) LOOP
lp_parser := xmlparser.newParser;
xmlparser.parseClob(lp_parser, meter_xml_rec.SOAP_RESPONSE);
lx_xmldoc := xmlparser.getDocument(lp_parser);
xmlparser.freeParser(lp_parser);
ln_doc_node := xmlDom.makeNode(lx_xmldoc);
ls_batch_number := xslProcessor.valueOf(ln_doc_node, 'AssetGetListResponse/AssetGetListResult/AssetFeed/AccountID');
lnl_product := xslprocessor.selectNodes(ln_doc_node, 'AssetGetListResponse/AssetGetListResult/a:AssetFeed');
li_product_max := xmlDom.getLength(lnl_product)-1;
FOR li_product_cnt IN 0..li_product_max LOOP
ln_product := xmlDom.item(lnl_product, li_product_cnt);
ls_batch_item := xslProcessor.valueOf(ln_product, 'AccountName');
END LOOP;
END LOOP;
END;
OUTPUT:
=========================================
3:32:41 PM *
**3:32:41 PM ORA-20100: Error occurred while processing: Namespace prefix 'a' used but not declared.**
3:32:41 PM ORA-06512: at "SYS.XSLPROCESSOR", line 22
3:32:41 PM ORA-06512: at "SYS.XSLPROCESSOR", line 502
3:32:41 PM ORA-06512: at line 50
3:32:41 PM *** Script stopped due to error ***
3:32:41 PM End SQL Editor ExecutionHi,
Something like this :
lnl_product := xslprocessor.selectNodes(
ln_doc_node
, '/s:Envelope/s:Body/AssetGetListResponse/AssetGetListResult/a:AssetFeed'
, 'xmlns:s="http://schemas.xmlsoap.org/soap/envelope/", xmlns="http://dev.services.xerox.com", xmlns:a="http://schemas.datacontract.org/2004/07/Xerox.MPS"'
li_product_max := xmlDom.getLength(lnl_product)-1;
FOR li_product_cnt IN 0..li_product_max LOOP
ln_product := xmlDom.item(lnl_product, li_product_cnt);
ls_batch_item := xslProcessor.valueOf(ln_product, 'a:AccountName', 'xmlns:a="http://schemas.datacontract.org/2004/07/Xerox.MPS"');
END LOOP;
...Or, using a single query :
SQL> SELECT extractValue(value(x), '/AssetFeed/AccountID', 'xmlns="http://schemas.datacontract.org/2004/07/Xerox.MPS"') as AccountID
2 , extractValue(value(x), '/AssetFeed/AccountName', 'xmlns="http://schemas.datacontract.org/2004/07/Xerox.MPS"') as AccountName
3 , extractValue(value(x), '/AssetFeed/AssetID', 'xmlns="http://schemas.datacontract.org/2004/07/Xerox.MPS"') as AssetID
4 , extractValue(value(x), '/AssetFeed/AssetNumber', 'xmlns="http://schemas.datacontract.org/2004/07/Xerox.MPS"') as AssetNumber
5 , extractValue(value(x), '/AssetFeed/SerialNumber', 'xmlns="http://schemas.datacontract.org/2004/07/Xerox.MPS"') as SerialNumber
6 FROM temp_table t
7 , TABLE(
8 XMLSequence(
9 EXTRACT(
10 XMLType(t.soap_response)
11 , '/s:Envelope/s:Body/AssetGetListResponse/AssetGetListResult/a:AssetFeed'
12 , 'xmlns:s="http://schemas.xmlsoap.org/soap/envelope/", xmlns="http://dev.services.xerox.com", xmlns:a="http://schemas.datacontract.org/2004/07/Xerox.MPS"'
13 )
14 )
15 ) x
16 WHERE t.call_id = 2
17 ;
ACCOUNTID ACCOUNTNAME ASSETID ASSETNUMBER SERIALNUMBER
de5862bf-f223-e011-bd3b-0024e861b15c MPS-API Sandbox ecf1545a-f1e9-e011-8a8a-0024e861b15c 57119B28 UTU101993N
de5862bf-f223-e011-bd3b-0024e861b15c MPS-API Sandbox b33b5160-f1e9-e011-8a8a-0024e861b15c 7EE42ADC PBB015012 -
How to save a 4D Array in a File and load it later on?
Hello,
I am trying to save a 4D Array (Array[4000] [3] [20] [5]) of UINT in a File. I can do it through "write in binary File". But then I can´t load it. I know I can transform my Array down to 1D Array of 1.200.000 Elements (4000*3*20*5) of UINT. When I load it, I have to transform it back (with a lot of "for-looping") back to 4D. But is there an easier way of doing that?
I was not able to find a solution in this forum - I am sorry if I made a new thread if there is already a solution in this forum.
Best regards
LabVIEW 2011
Solved!
Go to Solution.As Lynn said, there should be no extra code required.
When writing, make sure that "prepend size" is true (true is default) and when reading, wire an empty 4D array of the correct representation to the "data type" input.
(I also assume that your LabVIEW version is not extremely ancient)
LabVIEW Champion . Do more with less code and in less time . -
Hi,
I have to implement the following scenario in SSIS but don't know how to do since I never worked with SSIS before. Please help me.
I have 20 different text files in a single folder and 20 different tables corresponding to each text file in SQL Server 2008 R2 Database. I need to extract the data from each text file and
load the data into corresponding table in Sql Server Database. Please guide me in how many ways I can do this and which is the best way to implement this job. Actually I have to automate this job. Few files are in same format(with same column names
and datatypes) where others are not.
1. Do I need to create 20 different projects ?
or
Can I implement this in only one project by having 20 packages?
or
Can I do this in one project with only one package?
Thanks in advance.As I said I don't know how to use object data type, I just given a shot as below. I know the following code has errors can you please correct it for me.
Public
Sub Main()
' Add your code here
Dim f1
As FileStream
Dim s1
As StreamReader
Dim date1
As
Object
Dim rline
As
String
Dim Filelist(1)
As
String
Dim FileName
As
String
Dim i
As
Integer
i = 1
date1 =
Filelist(0) =
"XYZ"
Filelist(1) =
"123"
For
Each FileName
In Filelist
f1 = File.OpenRead(FileName)
s1 = File.OpenText(FileName)
rline = s1.ReadLine
While
Not rline
Is
Nothing
If Left(rline, 4) =
"DATE"
Then
date1 (i)= Mid(rline, 7, 8)
i = i + 1
Exit
While
End
If
rline = s1.ReadLine
End
While
Next
Dts.Variables(
"date").Value = date1(1)
Dts.Variables(
"date1").Value = date1(2)
Dts.TaskResult = ScriptResults.Success
End
Sub -
Javascript request on non well-formed xml file in Safari
Hi,
I make an AJAX request to get a non well-formed xml file. On Internet Explorer (domNode is empty) and Firefox (domNode is not empty but a tag "parsererror" is present), I can know if the document is non well-formed but on Safari the request seems to be ok, I get a part of the non well-formed file (until the error).
I would like to say if I can make the difference between a well-formed xml file and a non well-formed xml file (with an AJAX request) on Safari.
Thanks
JulienI have built a desktop application that can use these
calls to check if the xml contained in the document
called "file" is well formed.
Ok. So, the application works fine then?
DocumentBuilderFactory domFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder domBuilder =
lder domBuilder = domFactory.newDocumentBuilder();
domBuilder.parse(file);
They are part of the javax.xml.parsers.*; package.
Problem is that to serve this I need to put it in an
applet but since I have to write the xml string to a
file local to the server the applet is not working.
Huh? You lost me there. Are you getting security exceptions from the applet? If yes, you need to sign the applet. Otherwise, what is not 'working' in the applet compared to the application? Also, why do you need to first write it to a file?
My question is if anyone knows of some classes in the
API that will allow me to check if a String of XML is
well formed or not.
If the document is not well-formed, the parse() call will throw an exception. Catch this and process as needed.
I basically need to get a string from a field in a
data base in XML format and be able to test it
without first writing it to a document so I can get
the applet to work.
If you want to access an external database from an applet, you will need to sign the applet. You should not need to first write it to a file before parsing. Rather, simply use a stream (either InputStream or Reader) and wrap it in a StreamSource object.
If anyone knows something on this or has an
alternative suggestion please do tell.
Thanks.- Saish -
How to extract data from xml file and store that data inti data base table
Hii All
I have one table that table contains one column that column contain an XML file
I want to extract data from that XML file and want to store that extracted data into an other table.
That xml file has different different values
I want to store that values into table in diff diff columnsHi,
I am also facing the same problem.I have a .xml file and i need to import the data into the custom table in oracle database.
Can you please let me know if you know the solution how to do it in oracle apps.
Thanks, -
Catching a not well formed xml file
I have a method that parses many xml files and after each one is processed they are entered into a mysql database. My problem is that when an xml file is found not to be well formed the input process into the mysql database stops.
Thus, my question is: how do I get my program to stop trying to enter the failing file data into my mysql database and continue with the next one...at the same time that it tells me the name of the file that is causing the problem (this second part has been solved). My parsing method looks as follows:
private Document parseXmlFile(String _filename, boolean _validating){
try{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(_validating);
Document doc = factory.newDocumentBuilder().parse(new File(_filename));
return doc;
} catch(SAXException e){
System.out.println("Bad XML");
catch(ParserConfigurationException parserconfigurationexception){
catch(IOException ioexception){
System.out.println("Could not read source file: " + ioexception.getMessage());
return null;
}then, the method that calls for this method and the xml data extraction method (which also works) is as follows:
private void addFile(String _xmlPath){
Document xmlFile = parseXmlFile(_xmlPath, false);
addMyDoc(xmlFile);
}Thanks! that worked like a charm. I have one more question though. I know my program works because I have tested it every step of the way. However, I never contemplated that it could fail because of the a memory error. The program crashes randomly with a certain number of documents.
My program is suppose to handle about 3,000 documents at a time. And it does, if I break it up the parsing from the mysql input. If I place both pieces together, I get the following error that I don't even know how to begin to fix or diagnose (I am using eclipse for lack of experience running java on the command line):
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
at java.util.Vector.<init>(Vector.java:111)
at java.util.Vector.<init>(Vector.java:124)
at java.util.Vector.<init>(Vector.java:133)
at org.apache.xerces.dom.DeepNodeListImpl.<init>(Unknown Source)
at org.apache.xerces.dom.ElementImpl.getElementsByTagName(Unknown Source)
at form4Code.Form4Db.addDerTranLine(Form4Db.java:1072)
at form4Code.Form4Db.addFile(Form4Db.java:53)
at form4Code.Form4Db.loadFiles(Form4Db.java:44)
at form4Code.Form4Db.run(Form4Db.java:36)
at form4Code.Form4Db.setDirectory(Form4Db.java:32)
at form4Code.FindXml.setDirectory(FindXml.java:28)
at form4Code.FindXml.<init>(FindXml.java:10)
at form4Code.Run.go(Run.java:36)
at form4Code.InsiderPanel$2.actionPerformed(InsiderPanel.java:133)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)Edited by: jsidgman on Feb 24, 2008 9:59 AM -
Parse XML file and extract data
I'd like to parse an XML file and get some data extracted as columns.
Input file country.xml:
<?xml version="1.0" encoding="UTF-8"?>
<MAS Action="Insert">
<Country ObjectId="100000000000000009" VersionId="8"><Id>1</Id><NlTexts><Name Language="de">Land1</Name><Name Language="en">Country1</Name></NlTexts></Country>
<Country ObjectId="100000000000000033" VersionId="2"><Id>2</Id><NlTexts><Name Language="de">Land2</Name><Name Language="en">Country1</Name></NlTexts></Country>
</MAS>
I'd like to parse the xmlfile in order to get the following output
Required result:
col1 col2 col3
1 Land1 Country1
2 Land2 Country2
or alternatively
col1 col2
1 Land1
1 Country1
2 Land2
2 Country2
I tried extract-function
select extract((XMLTYPE(BFILENAME('XML_DAT_DIR', 'country.xml'),
NLS_CHARSET_ID('AL32UTF8'))) , '/*/*/Id') as "xdata"
from dual;
xdata
<Id>1</Id><Id>2</Id>
and XMLTABLE (but how can I add the countries now)
SELECT *
FROM XMLTABLE('/*/*/Id'
PASSING XMLTYPE(BFILENAME('XML_DAT_DIR', 'country.xml'),
NLS_CHARSET_ID('AL32UTF8'))
COLUMN_VALUE
<Id>1</Id>
<Id>2</Id>
DB version 11.2.0.3 on Windows 64bit
Thanks,
TimHere are a few examples.
For your required output :
SELECT *
FROM XMLTable(
'/MAS/Country'
passing XMLType(bfilename('TEST_DIR', 'country.xml'), nls_charset_id('AL32UTF8'))
columns col1 number path 'Id'
, col2 varchar2(30) path 'NlTexts/Name[1]'
, col3 varchar2(30) path 'NlTexts/Name[2]'
or, if the Language attribute is significant :
SELECT *
FROM XMLTable(
'/MAS/Country'
passing XMLType(bfilename('TEST_DIR', 'country.xml'), nls_charset_id('AL32UTF8'))
columns col1 number path 'Id'
, col2 varchar2(30) path 'NlTexts/Name[@Language="de"]'
, col3 varchar2(30) path 'NlTexts/Name[@Language="en"]'
For your alternate output :
SELECT x1.col1
, x2.col2
--, x2.col3
FROM XMLTable(
'/MAS/Country'
passing XMLType(bfilename('TEST_DIR', 'country.xml'), nls_charset_id('AL32UTF8'))
columns col1 number path 'Id'
, names xmltype path 'NlTexts/Name'
) x1
, XMLTable(
'/Name'
passing x1.names
columns col2 varchar2(30) path '.'
--, col3 for ordinality
) x2
(uncomment col3 to see what it does)
or, in a shorter way :
SELECT *
FROM XMLTable(
'for $i in /MAS/Country
, $j in $i/NlTexts/Name
return element r { $i/Id, $j }'
passing XMLType(bfilename('TEST_DIR', 'country.xml'), nls_charset_id('AL32UTF8'))
columns col1 number path 'Id'
, col2 varchar2(30) path 'Name' -
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. -
How to generate GUI code from parsed XML file?
hai,
I have to generate GUI code after parsing any configuration XML file as input.Now i have parsed my XML file and got its attributed and i want to get some idea of how to map the parsed XML attributes to the java code to build GUI code.Hello,
1. I like to create data type from a XML file structure, which contains the data structure ?
XML fields will need to be taken note of to see which is repeating or not. You can also load the XML into a third-party tool such as Altova XML Spy and then generate an XSD from there. You will need to import the XSDs into PI under external definitions. However, this does not guarantee business interoperability, as such, it is always best to ask the provider for the XSDs or WSDL. It will also save you a lot of time from guessing which fields are needed or not.
2. How to create custom node function in graphical mapping editor ?
In your graphical mapping editor, on the lowest left corner, there is an icon there that says Create New Function. You must take into account their return types:
1. Single Values = String
2. Queue/Context (no return type) thus resultList is used.
Hope this helps,
Mark -
How to export a data as an XML file from oracle data base?
could u pls tell me the step by step procedure for following questions...? how to export a data as an XML file from oracle data base? is it possible? plz tell me itz urgent requirement...
Thankz in advance
BalaSQL> SELECT * FROM v$version;
BANNER
Oracle DATABASE 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS FOR 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
5 rows selected.
SQL> CREATE OR REPLACE directory utldata AS 'C:\temp';
Directory created.
SQL> declare
2 doc DBMS_XMLDOM.DOMDocument;
3 xdata XMLTYPE;
4
5 CURSOR xmlcur IS
6 SELECT xmlelement("Employee",XMLAttributes('http://www.w3.org/2001/XMLSchema' AS "xmlns:xsi",
7 'http://www.oracle.com/Employee.xsd' AS "xsi:nonamespaceSchemaLocation")
8 ,xmlelement("EmployeeNumber",e.empno)
9 ,xmlelement("EmployeeName",e.ename)
10 ,xmlelement("Department",xmlelement("DepartmentName",d.dname)
11 ,xmlelement("Location",d.loc)
12 )
13 )
14 FROM emp e
15 , dept d
16 WHERE e.DEPTNO=d.DEPTNO;
17
18 begin
19 OPEN xmlcur;
20 FETCH xmlcur INTO xdata;
21 CLOSE xmlcur;
22 doc := DBMS_XMLDOM.NewDOMDocument(xdata);
23 DBMS_XMLDOM.WRITETOFILE(doc, 'UTLDATA/marco.xml');
24 end;
25 /
PL/SQL procedure successfully completed.
.
Maybe you are looking for
-
How do I move contacts from my old non-iPhone?
I have a Motorola Bravo and just got an iPhone 5 from ATT. How can I get my contacts from the Bravo to the iPhone? I've already copied the contacts to the SIM. ATT support shows that's the first step. However, under the "Copy To" portion, all it men
-
Zend studio 8.0 and flex 4 plugin integration problem(please help!)
hello every body, actually i have installed Zend Studio 8.0 is built on Helios( which is currently the latest one) and trying to integrate flash builder 4(flex 4) plugin, but when i point to (C:\Program Files\Zend\Zend Studio - 8.0.0) folder the f
-
The best use of my MacBook and Logic Pro
Hi i have this machine 2.4 intel Core 2 Duo 667 Ram 4 Gigabite I use Logic Pro 9.1.1 I mainly work with midi i use Kontact Philarmonic La strings all that stuff hard disk is internal 250 Gbite What is the best way for me to go.(Use the Kontact as mul
-
CS5 frozen when iMac wakes from sleep mode
This problem just started, and I don't know if it's an INDD problem or a Finder problem. When I wake my computer from sleep and try to access INDD I can't. I click on the application icon in the Dock and it won't come to the front. All my other appli
-
New installation. XE 11.2 Passwords don't work.
This is my first attempt at Oracle Database. OS: Windows XP Pro sp3 Install went ok. Specified a database Username and Application Express Username. Same password for both. Initially I was able to log in no problem. But have not been able to log in a