Get the tags and hierarchy as output
Hi gurus!
What I need to do is to get as output what tags i have in my xml. Also i need to know the hierarchy of these tags.
If my XML is this:
<root>
<person>
<name>Mary</name>
<role>Queen</role>
</person>
<person>
<name>George</name>
<role>King</role>
</person>
</root>I want my output to be something like:
Tag Parent
root null
person root
name person
role personThe important thing here is that i don't know what tags are in the XML file and therefore i have to to it this way.
I don't have any previous knowledge of XML parsing in pl SQL but I´m assuming this is best done somehow with xmltypes. So far i have experimented with an xmltype instance but I'm stuck.
Any help is greatly appreciated!!
My version is 10.2.0.1.0
Hey,
We ended up redoing the whole thing with xmldom. Below are snippets of the final solution that got the processing time down from about one hour to 4 minutes for a 4Mb XML file.
procedure getChild(node xmldom.DOMNode, Id_parent number) is
v_id number;
v_id_parent number := Id_parent;
nl_children xmlDom.DOMNodeList;
n xmlDom.DOMNode;
v_value varchar2(3000);
v_Name varchar2(3000);
begin
nl_children := xmldom.getChildNodes(node);
for i in 0..xmldom.getLength(nl_children)-1 loop
n := xmldom.item(nl_children, i);
v_Name := xmldom.getNodeName(n);
v_id := lueXml.ELEMENT_ID;
if xmldom.getNodeType(n) = xmldom.TEXT_NODE then
v_value := xmldom.getNodeValue(n);
update a_xml_taulu t set t.value = v_value
where t.id = lueXml.ELEMENT_ID;
commit;
else
lueXml.ELEMENT_ID := lueXml.ELEMENT_ID + 1;
insert into a_xml_taulu (id, tag, parent, value)
values (lueXml.ELEMENT_ID, v_Name, v_id_parent, '');
commit;
getChild(n, lueXml.ELEMENT_ID);
end if;
end loop;
end getChild;Which is called by
procedure readXMLfile is
directory varchar2(100) := 'testdir';
filename varchar2(100) := 'File.xml';
v_file bfile := bfilename(directory,filename);
v_nclob nclob;
v_dest_offset number := 1;
v_src_offset number := 1;
v_lang_context integer := DBMS_LOB.DEFAULT_LANG_CTX;
v_warning number;
v_xmltype xmltype;
doc xmldom.DOMDocument;
nl xmldom.DOMNodeList;
n xmldom.DOMNode;
v_root_tag varchar2(200);
begin
DELETE FROM a_xml_taulu;
DELETE FROM a_temp_xml_storage;
DELETE FROM a_temp_clob;
commit;
begin
dbms_output.put_line('Starting insert of a_temp_clob at time '||to_char(sysdate, 'HH:MM:SS'));
INSERT INTO a_temp_clob(id, file_name, xml_file, timestamp)
VALUES (1001, filename, empty_clob(), sysdate)
RETURNING xml_file INTO v_nclob;
DBMS_LOB.fileopen(v_file);
dbms_output.put_line('loading clob at '|| to_char(sysdate, 'HH:MM:SS'));
DBMS_LOB.loadclobfromfile(dest_lob => v_nclob,
src_bfile => v_file,
amount => DBMS_LOB.LOBMAXSIZE,
dest_offset => v_dest_offset,
src_offset => v_src_offset,
bfile_csid => nls_charset_id('AL16UTF16LE'),
lang_context => v_lang_context,
warning => v_warning);
DBMS_LOB.close(v_file);
dbms_output.put_line('loaded clob at '||to_char(sysdate, 'HH:MM:SS'));
INSERT INTO a_temp_clob(id, file_name, xml_file, timestamp)
VALUES(1001, filename, v_nclob, sysdate);
if v_warning > 0 then
Dbms_Output.Put_Line ('Warning');
end if;
end;
begin
dbms_output.put_line('Starting insert at time '||to_char(sysdate, 'HH:MM:SS'));
INSERT INTO a_temp_xml_storage VALUES(xmltype(to_clob(v_nclob)));
commit;
dbms_output.put_line('Ending insert at time '||to_char(sysdate, 'HH:MM:SS'));
select t.sys_nc_rowinfo$ into v_xmltype from a_temp_xml_storage t;
luexml.ELEMENT_ID := 0; -- this is a global variable
doc := DBMS_XMLDOM.newDOMDocument(v_xmltype);
nl := xmldom.getElementsByTagName(doc, '*');
n := xmldom.item(nl, 0);
v_root_tag := xmldom.getNodeName(n);
insert into a_xml_taulu (id, tag, parent, value)
values (lueXml.ELEMENT_ID, v_root_tag, null, '');
lueXml.getChild(n, luexml.ELEMENT_ID);
dbms_output.put_line('getChild iterations done at '||to_char(sysdate, 'HH:MM:SS'));
end;
end readXMLfile;Im sure this version could be further optimized but it is fast enough already...
Thank you all for you help in this matter!
Similar Messages
-
Lightroom is not saving metadata. I have done several things to save and I still get the tag that states is is not saved. I have also created 2 smart collections. One showing metadata has been changed and one showing metadata is not up to date. No matter what I do it is not showing in LR that it is saved. I spent 2 days with Seth Resnick trying to correct this and we re created my catalog. It was ok, until I imported new images and same problem. Now I have a new problem, when I bring image to PS it saves it but does not bring back to LR. Am I the only one out there who has this problem?
See:
How to use multiple iPods, iPads, or iPhones with one computer
What is the best way to manage multiple...: Apple Support Communities -
How to get the table_name and its count(*) in a SQL
Hi,
Can anybody tell me how to write a sql to get the table_name and its count(*) in a SQL:
Output should be:
table_name count(*)
XXX 261723
YYY 3343
Regards,
G. Rajakumar.hello
there r a lot ways
i'll suggest u two of them
1) the following dynamic sql procedure
DECLARE
TYPE array_type IS TABLE OF VARCHAR(30);
TYPE cur_typ IS REF CURSOR;
c1 cur_typ;
count1 integer;
tab_arr array_type;
querystr varchar2(200);
begin
SELECT table_name bulk collect into tab_arr FROM sys.all_all_tables ;
FOR I IN tab_arr.first..tab_arr.last LOOP
DBMS_OUTPUT.PUT(TAB_ARR(I));
querystr := 'select count(*) from ' ||TAB_ARR(I);
open c1 for querystr;
fetch c1 into count1;
EXIT WHEN c1%NOTFOUND;
dbms_output.put_line(count1);
END LOOP;
close c1;
END;
2) or use ANALYZE to analyze the tables and get the number of rows in the NUM_ROW column of DBA_TABLES view.
if u still have any problem mail me at [email protected]
shalini -
How can I get the Elapsed Time express to output in milliseconds?
I am trying to get the Elapsed Time express to output in milliseconds or in seconds to three decimal places. I am pretty new at this.
Thanks in advance!I'm not sure I understand your question. The output of the Elapsed Time Express VI is a DBL. It's already a floating point number. The default format for a numeric indicator is 6 digits of precision. You can change this in the properties for the indicator.
To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.
Attachments:
Example_VI.png 4 KB -
How to get the tag name of HTMLDocument?
I am now using JEditorPane to display and edit a html file.
My code is like this:
kit = new HTMLEditorKit();
doc = (HTMLDocument) (kit.createDefaultDocument());
editor.setEditorKit(kit);
editor.setDocument(doc);
editor.setContentType("text/html; charset=utf-8");
editor.getDocument();
[editor is the class JEditorPane, doc is HTMLDocument, kit is HTMLEditorKit]
When a user clicks on the pane, it's easy to me to get the caret position. However, how can I get the tag?
For example,
<p><font class="book">I am a boy.</font> Hello! </p>
On the pane, the position between "I am a boy" is clicked, I want to get the name of the tag - "font". Moreover, how can I get the class - "book" also?
Moreover, can I get the <p> tag also?
Many Thanks!
StephenHi Stephen,
is it possible to get the EditorKit from the EditorPane and then get the ViewFactory for the editor kit.
Since u have the some tags of the elements hardcoded in the HTMLEditorKit.HTMLFactory it will be handy i guess.
Let me know whether it helped or not so that either same method be approached or some other has to be tried.
Cheers,
Nagaraj -
Set by script the tag and/or the class of a paragraph style for HTML / EPUB export?
Is it possible to set by script the tag and/or the class of a paragraph style for HTML / EPUB export?
I found a way
tell application "Adobe InDesign CS6"
tell document 1
tell paragraph style 2
--get count of style export tag map
tell style export tag map 1 -- HTML , 2 = PDF
--get export class
--get export tag
set export tag to "H1"
set export class to "blue"
end tell
end tell
end tell
end tell
and its works
but thanks for help to use the class "style export tag map" -
I am trying to download a book on my ipad. It says I need to install itunes. I have itunes already. I frequently get a message to re-install itunes. I do, but I still get the message, and I still can't get the book on my ipad.
you can download a new installer and serial number from Adobe at Adobe - CS2 Downloads
-
I found an old iPod classic of mine that is synced to a computer that is long gone. I want to get the music and photos from this old iPod onto my new computer. Every time I hook the iPod up to my new computer it wants to delete what is on the iPod and replace with the contents of the iTunes that is currently on the new computer. I don't want to do that. I want to keep what is on the old iPod and transfer it to iTunes. Any help? Thanks!
See this excellent user tip from another forum member turingtest2 outlining the different methods and software available to help you copy content from your iPod back to your PC and into iTunes.
Recovering your iTunes library from your iPod or iOS device
B-rock -
Trying to get the Opening and Closing Balance, 0TOTALSTCK and 0VALSTCKVAL
Hi Experts, Good Day.
I am developing a query for Stock Balances, Using Custom cube created with copy from 0ic_c03.
I am trying to get the Opening and Closing Balance, based on Non-Cumulative KF - 0TOTALSTCK and 0VALSTCKVAL.
Both The KF's Behaviour for Exception Aggregat. = Last Value
I am using VARIABLE OFFSET as -1 to get Opening Balance, and just restriction for Closing Balance based on 0CALMONTH
Unfortunately i am getting data for the periods which does not have data in my Cube. It is taking the total value as closing balance for the periods which we don't have transaction in the cube.
For Ex. I have data for 09.2010 & 10.2010 a particular material, when i enter 08.2010 as input i am getting the total value of the material.
I hope you understand the problem and solution soon.
I will give you more explanation if needed.
Thanks in Advance....
Have a great Day Ahead.....
GopalNHi GopaIN,
can you explain us process you have done about initialization of data (2LIS_03_BX, cube compression)? it seams like there was data before 09.2010 and you load it with 2LIS_03_BX data source. That data is not in cube, but just used for update markers.
Edited by: Sasa Todorovic on Mar 25, 2011 9:48 AM -
How can I get the "Open" and "Save As" dialog boxes to open at larger than their default size?
How can I get the "Open" and "Save As" dialog boxes to open at larger than their default size? I would like them to open at the size they were previously resized like they used to in previous operating systems. They currently open at a very small size and the first colum is only a few letters wide necessitating a resize practically every time one wants to use it. Any help would be appreciated.
hi Prasanth,
select werks matnr from ZVSCHDRUN into table it_plant.
sort it_plant by matnr werks.
select
vbeln
posnr
matnr
werks
erdat
kbmeng
vrkme
from vbap
into table it_vbap
for all entries in it_plant
where matnr = it_plant-matnr and
werks = it_plant-werks.
and again i have to write one more select query for vbup.
am i right? -
I upgraded to OS Yosemite on my MacBook Air...and I cannot upgrade the Adobe Flash download that Adobe keeps asking me to download. I get the screen and when I click on the icon it just creates a new window but not download. Thoughts?
I just tried the link and it is just fine. If the GateKeeper pops up then open Security & Privacy preferences, click on the General tab, set the last radio button to Anywhere.
-
How can i get the itunes and apps store icon on my ipad desktop?
How can i get the itunes and apps store icon on my ipad desktop?
Google are supposed to be working on an iPad maps app.
-
when i try to set up my icloud account the system says it is sending me an email to verify. I never get the email and it is not in my spam filter. How can i get set up??
Make sure that your Apple ID is your email address and you do not have any other or old IDs associated with you. Go to www.appleid.apple.com and confirm this info. Make sure that the email address you are trying to sign up with is your primary one.
-
I'm new to Mac. I have an iPhone and a Mac Mini. My original iTunes was on a Windows computer that crashed. So, all of my iTunes Music and Movies are gone. How do I get the movies and music from my iPhone to the new Mac Mini?
If you still have the crashed Win computer, you may be able to recover your music and movies from the hard drive. If you have a friend with a hard drive USB connection kit and a PC, they should be able to help. Otherwise, check locally for computer services that might do that for you (I think Best Buy Geek Squad may be able to help). If the drive itself is in good shape, it shouldn't be too expensive.
-
I got an I pad for Christmas and had to return it and they gave me a new one. Is there a way I can get the books and apps I purchased without paying for them again?
Downloading past purchases from the App Store, iBookstore, and iTunes Store: http://support.apple.com/kb/HT2519
Maybe you are looking for
-
Need advice about new project!!
I come from a dvd background and more recently a online video background (lost of h.264 stuff). I have a client who would like me to do a training DVD-ROM. Shoot the footage - easy Edit the multi cams - easy Add screen shots of the software and chang
-
Transactions Routing randomly to the incorrect bpel processes..
Hi, We are having a design scenario in B2B and BPEL Integration as mentioned below: 1. For a given Business Action defined in B2B , for a given revision ---Business Protocol : EDI X12 over Generic Exchange ---Document Protocol EDI_X12 -- we have a gi
-
Slow Firefox tried everything including reinstall. Slow in Safari too.
For 24 hours Firefox has been really slow to load. This is on my computer only - browsing on my ipad is fast and good. I tried the same on my computer with another browser and it is equally slow. I have tried all the suggestions including reinstallin
-
Hello Experts, Can someone let me know the procedure of logical partioning a cube. I am actually designing a cube for each year and i would want to know the whole process ( the configuration in BW including ). All answers would be duly rewarded. Than
-
How to change language?e
Hi I have danish language in my photoshop cs6, but i want to have english. Anyone know how to change?