Retrieve / Search specific Node from XML File
Hello,
i have a question about reading (searching) XML File within PL SQL:
There is a XML file with following structure:
<root>
<Hnode1 attr1="value1" />
<Hnode2 attr1="value1" />
<node1_of_Hnode2 id="10" personname="Steven"/>
<node2_of_Hnode2 id="20" personname="Christian"/>
<node3_of_Hnode2 id="30" personname="Arnold"/>
<Hnode2/>
<root/>How it is possible to filter a node by one of its attribute value. For example:
I know the id of a person - lets say id =20. In this case i would like to get the whole node (in this case node2_of_Hnode2) to get the personname => "Christian".
Just like a SELECT statement (WHERE ID = 20)
Is there a possibility the get this by one command or should it be looped over all Rows of the Document?. Can you please provide an example for me.
Thank you in advice!
Database version is 10.Sorry, that's not a version.
For example :
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
How to use the extraction of values?
1.Better in Select statement; assigning directli in a variable or using xmlquery function?.PL/SQL or SQL calls to XMLType methods such as extract() or getStringVal() should be equivalent (putting aside the context switch).
However, none of them is the correct way to retrieve a scalar value from a given node.
You must use extractValue() function instead (SQL only) for release < 11.2 and XMLCast/XMLQuery starting with 11.2.
One more Question:
I have seen a lot of options to handle with XML Files.
So in my case only querying data in XML Files is relevant.
I have seen many APIs called XMLDOM, DMBS_XMLDOM, XMLTYPE...
When to use these APIS. Can you give me some input on that please?That's a broad topic.
A relevant answer will depend on your requirement.
- Do you have to process large files, and if so how large?
- Is performance/memory management a concern for you?
- Do you want to extract single values, or process the XML content as relational data?
If you have any specific test case to show us, please post in the {forum:id=34} forum, and make sure you include all the necessary details (see the FAQ).
Edited by: odie_63 on 23 févr. 2012 11:35
Similar Messages
-
How to delete a perticular node from xml file using java code
Hii All,
Now i am trying to delete a perticular node from xml file.Like...
XML file:
<Licence>
<SERVER>
<was id="1">1</was>
<was id="2">2</was>
</SERVER>
</LICENCE>
I am working in messaging service using JABBER framework with whiteboard facility.
Here Some commands i have created to add,modify,delete nodes from xml file.They Are
1.If u want to add a new node then.
create Licence.SERVER <ss id="3">ddd</ss> lic.xml
(here u want to add a new node called "ss" under Licence.SERVER.
And lic.xml is tyhe xml file name where it was saved.
2.If u want to delete a node(Suppose <was id="1">),then the command should be
delete Licence.SERVER.was:id='"1" lic.xml
A problem arises that here it find two was attributes.And it delete the last was attribute,not the requested node.
PLEASE HELP ME IN SOLVING THIS CODE..
------------------------------------Looks like you clicked on "Post" before you pasted in the code you were talking about.
-
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 retrieve image from XML file
Hi All,
I am new to XML. So any best guidance is appreciated.
The application requirement is to display image retrived from uploaded xml file in file upload section of our application. And store that image in database.
In my XML file , images & strings & numbers & booleans are there . I am able to save everything in database except images .
I am using JSF, Seam & Hibernate combination. In my Hibernate entity class i took BLOB datatype for image.
I am using following tags in my Xhtml file to display image
<s:graphicImage value="#{hibernateentitybean.picBlobtype}" height="200" width="200">
<s:transformImageSize width="200" height="200" />
<s:transformImageType contentType="image/jpeg"/>
But image is not displayed in Xhtml file
I am using org.w3c.dom.Document for retrieving node name & corresponding value in that node in XML file.
I am getting code like below for Image when i am logging all values from XML files in my bean class .
x0lGQRQAAAABAAAAAAAAAFJHAQARAAAAVwBhAHQAZQByACAAbABpAGwAaQBlAHMALgBqAHAAZwAAAP/Y/+AAEEpGSUYAAQIBAGAAYAAA/+0YLl
I want to convert this value to image. So i can convert image to bytes and store in BLOB.
Can anyone guide me ? or any other approach .
Thanks in advance for any reply.
Regards,
NareshDan_Koldyr wrote:
agree, it's really odd. Just reread OP and it says:
NareshDharmiVatsal wrote:
want to convert this value to image. In any case it doesn't get worth then another single code line:
final String cdata = "x0lGQRQAAAABAAAAAAAAAFJHAQARAAAAVwBhAHQAZQByACAAbABpAGwAaQBlAHMALgBqAHAAZwAAAP/Y/+AAEEpGSUYAAQIBAGAAYAAA/+0YLl";
final sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
final byte[] data = decoder.decodeBuffer(cdata);
Blob blob = new SerialBlob(data);//or what ever other DB-specific blob implementaiton Did i answered original question? Any more comments to my first replay?I can comment on this latest code. The package sun.misc is private to Sun (Oracle now of course). It is undocumented and may change or be removed altogether in a future release. There is a good free open source Base64 decoder in the Jakarta Commons Codec library. -
How to ignore a node while reading data from XML file
Hi All,
I have a XML file that i am reading that XML file using XMLStreamReader and then i need to create another XML file that has specific nodes(from the database).
I need to ignore nodes(with values) that are not in the database and while creating the XML file, only nodes that are it the database should be written in the new file.*
For eg.
<XML>
<Stud>
<Name>XYZ</Name>
<Roll>1</Roll>
<Class>1</Class>
</Stud>
<Stud>
<Name>ABC</Name>
<Roll>2</Roll>
<Class>1</Class>
</Stud>
</XML>
In database i have only two node :<Name> and <Roll>.
So, my new XML will be
<XML>
<Stud>
<Name>XYZ</Name>
<Roll>1</Roll>
</Stud>
<Stud>
<Name>ABC</Name>
<Roll>2</Roll>
</Stud>
</XML>Hi gborges,
Since you're new to LabVIEW, I thought I would post a few helpful links. A great way to learn some LabVIEW basics is to look over the introductions --
Three Hour LabVIEW Introduction Course
Six Hour LabVIEW Introduction Course
You might even want to think about signing up for the LabVIEW Basics I & II courses which are taught by Applications Engineers. You can always search for KnowledgeBases and, of course, you already know about our forums!
Happy coding,
Megan B.
National Instruments -
Efficient searching in a large XML file for specific elements
Hi
How can I search in a large XML file for a specific element efficiently (fast and memory savvy?) I have a large (approximately 32MB with about 140,000 main elements) XML file and I have to search through it for specific elements. What stable and production-ready open source tools are available for such tasks? I think PDOM is a solution but I can't find any well-known and stable implementations on the web.
Thanks in advance,
Behrang Saeedzadeh.The problem with DOM parsers is that the whole document needs to be parsed!
So with large documents this uses up a lot of memory.
I suggest you look at sometthing like a pull parser (Piccolo or MPX1) which is a fast parser that is program driven and not event driven like SAX. This has the advantage of not needing to remember your state between events.
I have used Piccolo to extract events from large xml based log files.
Carl. -
How to retrieve value from xml file
hi all,
can somebody pls tell me how to retrieve value from xml file using SAXParser.
I want to retrieve value of only one tag and have to perform some validation with that value.
it's urgent .
pls help me out
thnx in adv.
rituhi shanu,
the pbm is solved, now i m able to access XXX no. in action class & i m able to validate it. The only thing which i want to know is it ok to declare static ArrayList as i have done in this code. i mean will it affect the performance or functionality of the system.
pls have a look at the following code snippet.
public class XMLValidator {
static ArrayList strXXX = new ArrayList();
public void validate(){
factory.setValidating(true);
parser = factory.newSAXParser();
//all factory code is here only
parser.parse(xmlURI, new XMLErrorHandler());
public void setXXX(String pstrXXX){
strUpn.add(pstrXXX);
public ArrayList getXXX(){
return strXXX;
class XMLErrorHandler extends DefaultHandler {
String tagName = "";
String tagValue = "";
String applicationRefNo = "";
String XXXValue ="";
String XXXNo = "";
XMLValidator objXmlValidator = new XMLValidator();
public void startElement(String uri, String name, String qName, Attributes atts) {
tagName = qName;
public void characters(char ch[], int start, int length) {
if ("Reference".equals(tagName)) {
tagValue = new String(ch, start, length).trim();
if (tagValue.length() > 0) {
RefNo = new String(ch, start, length);
if ("XXX".equals(tagName)) {
XXXValue = new String(ch, start, length).trim();
if (XXXValue.length() > 0) {
XXXNo = new String(ch, start, length);
public void endElement(String uri, String localName, String qName) throws SAXException {
if(qName.equalsIgnoreCase("XXX")) {
objXmlValidator.setXXX(XXXNo);
thnx & Regards,
ritu -
Hello,
I need to import some specific nodes from a large XML file, into an Oracle table, containing columns not necessarily labeled identical to the XML nodes.
Can it bee done from within HTMLDB?
Thanks for the help,
Arie.Arie,
You can certainly upload files with HTML DB, search the forum for file upload. Once you uploaded your XML file, you can parse it and process it however you want using Oracleâs XML DB features. You can post XML DB specific questions here:
XML DB
Regards,
Marc -
Load data from XML files into BI
Hi All,
Can any one guide me through the steps which involve in loading data from XML files into BI?
Thanks
SantoshHi James,
I have followed upto step No: 12 .
Please could you let me know how to link the XML file on my local drive to BI,
I am not able to find figure out where to specify the path of the XML file to be loaded into BI.
Thanks In Advance
Regards,
San
1. Create a Infosource(ZIS), with transfer structure in accordance with the structure in the XML file. (You can open the XML file with MS Excel.This way you can get to know the structure).
2. Activate the transfer rules.
3. After activation ;from the Menu Bar , Select Extras>Create BW Datasource with SOAP connection.
4.Now Activate the Infosurce again, this creates an XML based Datasource(6AXXX...)
5.These steps would create two sub nodes under the Infosource(ZIS).
6.Select Myself system and create a data package and execute it run in Init mode(without Data Transfer).
7. This would create an entry in RSA7(BW delta Queue)
8. Again create another Delta Infopackage under it, and run it. Now the Datasource(6AXXXXXX..) would turn green in RSA7.
9.In Function builder(SE37) select your FM( do a search ,F4, on the datasource 6AXXX....) .
10.Inside this RFC based FM , from the Menu Bar select Utilities>more Utilities>Create Web services>From Function module.
11.A wizard will guide you through the next steps .
12.once this is done a Web serrvice would be enabled in WSADMIN. Select your FM and execute it.
13.From here you can upload the data from XML file into BW delta queue.
Edited by: Santosh on Nov 30, 2008 2:22 PM -
HOW to retrieve PURCHASE ORDER DATA from archieve file and print a report
Dear all
1) I have retrieve purchase order data from archived files.
2) print purchase order data and created pdf file.
VIJ.............
Moderator message - Please ask a specific question - post locked
Edited by: Rob Burbank on Apr 28, 2009 12:00 PMDear all
1) I have retrieve purchase order data from archived files.
2) print purchase order data and created pdf file.
VIJ.............
Moderator message - Please ask a specific question - post locked
Edited by: Rob Burbank on Apr 28, 2009 12:00 PM -
Data Load from XML file to Oracle Table
Hi,
I am trying to load data from XML file to Oracle table using DBMS_XMLStore utility.I have performed the prerequisites like creating the directory from APPS user, grant read/write to directory, placing the data file on folder on apps tier, created a procedure ‘insertXML’ to load the data based on metalink note (Note ID: 396573.1 How to Insert XML by passing a file Instead of using Embedded XML). I am running the procedure thru below anonymous block to insert the data in the table.
Anonymous block
declare
begin
insertXML('XMLDIR', 'results.xml', 'employee_results');
end;
I am getting below error after running the anonymous block.
Error : ORA-22288: file or LOB operation FILEOPEN failed”
Cause : The operation attempted on the file or LOB failed.
Action: See the next error message in the error stack for more detailed
information. Also, verify that the file or LOB exists and that
the necessary privileges are set for the specified operation. If
the error still persists, report the error to the DBA.
I searched this error on metalink and found DOC ID 1556652.1 . I Ran the script provided in the document. PFA the script.
Also, attaching a document that list down the steps that I have followed.
Please check and let me know if I am missing something in the process. Please help to get this resolve.
Regards,
SankalpThanks Bashar for your prompt response.
I ran the insert statement but encountered error,below are the error details. statement.
Error report -
SQL Error: ORA-22288: file or LOB operation FILEOPEN failed
No such file or directory
ORA-06512: at "SYS.XMLTYPE", line 296
ORA-06512: at line 1
22288. 00000 - "file or LOB operation %s failed\n%s"
*Cause: The operation attempted on the file or LOB failed.
*Action: See the next error message in the error stack for more detailed
information. Also, verify that the file or LOB exists and that
the necessary privileges are set for the specified operation. If
the error still persists, report the error to the DBA.
INSERT statement I ran
INSERT INTO employee_results (USERNAME,FIRSTNAME,LASTNAME,STATUS)
SELECT *
FROM XMLTABLE('/Results/Users/User'
PASSING XMLTYPE(BFILENAME('XMLDIR', 'results.xml'),
NLS_CHARSET_ID('CHAR_CS'))
COLUMNS USERNAME NUMBER(4) PATH 'USERNAME',
FIRSTNAME VARCHAR2(10) PATH 'FIRSTNAME',
LASTNAME NUMBER(7,2) PATH 'LASTNAME',
STATUS VARCHAR2(14) PATH 'STATUS'
Regards,
Sankalp -
How to parse contents from XML file in Java
Hi All,
I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
How to parse Contents of XML file??
Thanks in advance,
Rajendra.Hi All,
I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
How to parse Contents of XML file??
Thanks in advance,
Rajendra. -
How to show records from xml file
HI All
I have created one region its actually search region
which having 5 items and result table region
I want to search records based on that 5 items and want to show output in table
I have table name as hr_api_transactions which contains lot of columns
and that table also contain one column
name as TRANSACTION_DOCUMENT of type CLOB()
that columns xml files for each record
I want to extract data from that xml file and want to display.I have created one region on seeded page
in that region I have created one table for output
that region is search region
which having 5 items of textfield and 2 items of type submit button
GO and Clear
I want to search based on that 5 items
I want to display records in table that I have created on that region
I have one seeded table
that contain one column
that column contain xml file for each individual records
that xaml file contains values what I want to display
MY problems are
how can I extract data from xml file?
how can I show all values for each records on that table?
how can I search based on that 5 items?
now I am able to find out single value from that XML file
by using SQL command
select xmltype(transaction_document).extract('//IrcPostingContentsVlEORow/CreationDate/text()').getStringVal() CreationDate
from hr_api_transactions
where transaction_ref_table = 'PER_ALL_VACANCIES'
and transaction_ref_id = 4693;how can I extract more than one records from that XML file -
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. -
Passing Parameters from XML file to Java Application
Can any one help me to know the way of passing values from XML file to Java Application..
Thanx in advanceWith the Processing Instructions <?name pidata?>
Get the Nodes in a Document.
Node node;
if(node.getNodeType()==Node.PROCESSING_INSTRUCTION_NODE)
//String param=node.getData();
Maybe you are looking for
-
Calculate Present, absent days
in my asp.net+vb+sql web is was trying to make a calculation of absent days. There are two dropdown lists to select Month , Year if i select Jan and 2015 in drop downlists. i want out put as MID, Name, Room_No, Preasnt_days, absent_days i made the t
-
Help on Database submit when mass document change
I called function ''FI_ITEMS_MASS_CHANGE'' to change voucher text, and wait 1 second, The problem is I can't make sure all of the items are changed, just most of them are changed!!!! code is as follow: CALL FUNCTION 'FI_ITEMS_MASS_CHANGE' EXPOR
-
Add multiple users to SCCM 2012 collection
I have a list of users and I want to add the users to SCCM collection. Is there any way by VB script to do this? \m/
-
In OS 10.4, I could play an audio file in a column view Finder window. In 10.5, I only get some goofy generic icon. What happened? How can I get OS 10.5 to play audio files in the Finder window like 10.4 did? If there is no preference setting that wi
-
The perfect presentation machine?
Hi, y'all: This may be too basic, but we really need help making our CEO happy! He's very hard to please . . . The machine needs to be light enough to be portable, plug in and play well with projectors, and only run outlook and play the videos. Help!