How to display appcmd /config xml data into a single table
Hi,
I extracted my IIS sites using appcmd
appcmd /site /config /xml > c:\temp\iisconfig.xml
afterwhich I would like to grab the data from this xml and export into excel file
[xml]$iisconfig = get-content c:\temp\iisconfig.xml
I would like to get the Site Name, Bindings, Physical Directory Path and AppPool from this xml file and output to a excel file
#Physical Path Directory
$iisPhysicalPath = $iisconfig.appcmd.site.site.application.VirtualDirectory.PhysicalPath
#Application Pool
$iisAppPool = $iisconfig.appcmd.site.site.application.applicationPool
#Site Details (Site Name, Binding)
$iisSite = $iisconfig.appcmd.site
It doesn't have a single command to output into a table. How do I combine all these code and display in a single table?
Jeron
Try it like this:
$sites=[xml](c:\windows\system32\inetsrv\appcmd.exe list site /xml)
$sites.appcmd.site
\_(ツ)_/
Similar Messages
-
How do I import one xml file into 3 separate tables in db?
I need to utilize xslt to import one xml file into 3 separate tables: account, accountAddress, streetAddress
*Notice the missing values in middleName, accountType
sample xml
<account>
<firstName>Joe</firstName>
<middleName></middleName>
<lastName>Torre</lastName>
<accountAddress>
<streetAddress>
<addressLine>myAddressLine1</addressLine>
<addressLine>myAddressLine2</addressLine>
</streetAddress>
<city>myCity</city>
<state>myState</state>
<postalCode>mypostalCode</postalCode>
</accountAddress>
<accountId>A001</accountId>
<accountType></accountType>
<account>
I need the following 3 results in 3 separate xml files in order for me to upload into my 3 tables.
Result #1
<rowset>
<row>
<firstName>Joe</firstName>
<lastName>Torre</lastName>
<accountId>A001</accountId>
<row>
<rowset>
Result #2
<rowset>
<row>
<addressId>1</address>
<city>myCity</city>
<state>myState</state>
<postalCode>myPostalCode</postalCode>
<row>
<rowset>
Result #3
<rowset>
<row>
<addressId>1</addressId>
<addressLineSeq>1</addressLineSeq>
<addressLine>myAddressLine1</addressLine>
<row>
<row>
<addressId>1</addressId>
<addressLineSeq>2</addressLineSeq>
<addressLine>myAddressLine2</addressLine>
<row>
<rowset>Use XSU to store in multiple tables.
"XSU can only store data in a single table. You can store XML across tables, however, by using the Oracle XSLT processor to transform a document into multiple documents and inserting them separately. You can also define views over multiple tables and perform insertions into the views. If a view is non-updatable (because of complex joins), then you can use INSTEAD OF triggers over the views to perform the inserts."
http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14252/adx_j_xsu.htm#i1007013 -
How to insert 4K of XML data into XMLType column?
I use OCCI and our Oracle version is 9.2.0.1.0. I have successfully been able to insert xml data (any size) into a clob column using "insert into...values(.., empty_clob()) returning c1 into :3"; and then using Statement::GetClob() to acquire a reference to the internal clob and populate it. I cannot seem to be able to do the same when the column type is of XMLType.
I could not find a single sample code which demonstrates inserting into a table with a XMLType column. Using SetDataBuffer(OCCI_SQLT_STR) with data over 4000 bytes does not work.
I'd greatly appreciate any feedback.Pretty sure this was a bug in the base 9.2 release which was fixed in a patch drop. Try 9.2.0.6 or later.
-
How to load xml data into a database table....
Hi All,
Iam new to this forum.I have an xmldoc table of xmltype(datatype).Iam able to insert xml data to it.I have another table called new_books.sql:
CREATE TABLE NEW_BOOKS
TITLE VARCHAR2(255) NOT NULL,
LINK VARCHAR2(80) NULL,
PUBLISHER VARCHAR2(255) NULL,
SUBJECT VARCHAR2(80) NULL,
PUBDATE VARCHAR2(40) NULL,
DESCRIPTION VARCHAR2(4000) NULL,
AUTHOR VARCHAR2(80) NULL,
PRIMARY KEY(TITLE)
Now i want to copy the data in the xmldoc table into the table new_books.sql.Is there any procedure to do that in PL/SQL?
Given below is the xmlfile:
- <rdf>
- <item>
<title>Enterprise SOA: Designing IT for Business Innovation</title>
<link>http://safari.oreilly.com/0596102380?a=102682</link>
<publisher>O'Reilly</publisher>
<creator>Thomas Mattern</creator>
<creator>Dan Woods</creator>
<subject>IT Infrastructure</subject>
<date>April 2006</date>
</item>
</rdf>
Thanks in Advance,
Gita.Assuming the table xmldoc(of xmltype) has this XML
SQL> select * from xmldoc;
SYS_NC_ROWINFO$
<rdf>
<item>
<title>Enterprise SOA: Designing IT for Business Innovation</title>
<link>http://safari.oreilly.com/0596102380?a=102682</link>
<publisher>O'Reilly</publisher>
<creator>Thomas Mattern</creator>
<creator>Dan Woods</creator>
<subject>IT Infrastructure</subject>
<date>April 2006</date>
</item>
</rdf>
SQL> INSERT INTO NEW_BOOKS(TITLE, LINK, PUBLISHER, SUBJECT)
2 select extractvalue(value(x),'/rdf/item/title') as title,
3 extractvalue(value(x),'/rdf/item/link') as link,
4 extractvalue(value(x),'/rdf/item/publisher') as publisher,
5 extractvalue(value(x),'/rdf/item/subject') as subject
6 from xmldoc x
7 ;
1 row created. -
How to process multiple rows of data into a single string
Hello,
I am trying to process multiple rows of text from an Oracle database into one field to display on a report as continuous text. Below is sample data. The text field is 55 characters wide so anything longer is broken into multiple rows. I need to recombine it for display.
line text
1 IN THE N.E. QUADRANT OF THE INTERSECTION OF THE FAIRFAX
2 COUNTY PARKWAY AND THE DULLES AIRPORT ACCESS AND THE T
3 OLL ROAD AND SOUTH OF SUNSET HILLS ROAD
I tried creating a formula field but it did not work, below is the code in Visual Basic syntax. I also tried using the Maximum() and UBound() functions without luck. I don't quite understand how to make the UBound() work; it threw a lot of errors.
Dim i As Number
Dim strLocDesc As String
For i = 1 To count({LDS_AR_RL_COMM.ART_LINE_NUM})
strLocDesc = strLocDesc & {LDS_AR_RL_COMM.ART_COMM_RMK}(i)
Next i
formula = strLocDesc
Any ideas on how to solve this?Hello Allison,
You can try this:
Create a formula called @StoreText, place it in the details and have the following code in it:
WhilePrintingRecords;
Global StringVar Text1;
Global StringVar TextRest;
if {field.line} = 1 then
Text1:= {field.text} else
if {field.line} >= 2 then
TextRest := TextRest+" "+{field.text};
In the Group Footer you can have a formula called @GetStoreText with the following code in it:
WhilePrintingRecords;
Global StringVar Text1;
Global StringVar TextRest;
Text1+varTextRest;
See how that works out for you.
Regards,
Zack -
How to Dump XML data into table
Hi All,
We have one schema on a server.
We have created the same schema with only table structures on another new server.
Now we got the data from the original schema as XML files corresponding to each table.
For Example, we have Employee table created newly on a new server. Now we have the XML file which has Employee data. We have to dump this XML data into new EMPLOYEE table.
We have to dump these XML files data into corresponding tables.
How can we achieve this?
Please help me..
Thanks in advanceLook at this example:
Assume you have the following XML in a tempxml table (tempxml could be an external table):
create table tempxml (xml xmltype);
insert into tempxml values (xmltype(
'<?xml version="1.0"?>
<ROWSET>
<ROW>
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
<JOB>CLERK</JOB>
<MGR>7902</MGR>
<HIREDATE>17-DEC-80</HIREDATE>
<SAL>800</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>20-FEB-81</HIREDATE>
<SAL>1600</SAL>
<COMM>300</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7521</EMPNO>
<ENAME>WARD</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>22-FEB-81</HIREDATE>
<SAL>1250</SAL>
<COMM>500</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7566</EMPNO>
<ENAME>JONES</ENAME>
<JOB>MANAGER</JOB>
<MGR>7839</MGR>
<HIREDATE>02-APR-81</HIREDATE>
<SAL>2975</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7654</EMPNO>
<ENAME>MARTIN</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>28-SEP-81</HIREDATE>
<SAL>1250</SAL>
<COMM>1400</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7698</EMPNO>
<ENAME>BLAKE</ENAME>
<JOB>MANAGER</JOB>
<MGR>7839</MGR>
<HIREDATE>01-MAY-81</HIREDATE>
<SAL>2850</SAL>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7782</EMPNO>
<ENAME>CLARK</ENAME>
<JOB>MANAGER</JOB>
<MGR>7839</MGR>
<HIREDATE>09-JUN-81</HIREDATE>
<SAL>2450</SAL>
<DEPTNO>10</DEPTNO>
</ROW>
<ROW>
<EMPNO>7788</EMPNO>
<ENAME>SCOTT</ENAME>
<JOB>ANALYST</JOB>
<MGR>7566</MGR>
<HIREDATE>19-APR-87</HIREDATE>
<SAL>3000</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7839</EMPNO>
<ENAME>KING</ENAME>
<JOB>PRESIDENT</JOB>
<HIREDATE>17-NOV-81</HIREDATE>
<SAL>5000</SAL>
<DEPTNO>10</DEPTNO>
</ROW>
<ROW>
<EMPNO>7844</EMPNO>
<ENAME>TURNER</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>08-SEP-81</HIREDATE>
<SAL>1500</SAL>
<COMM>0</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7876</EMPNO>
<ENAME>ADAMS</ENAME>
<JOB>CLERK</JOB>
<MGR>7788</MGR>
<HIREDATE>23-MAY-87</HIREDATE>
<SAL>1100</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7900</EMPNO>
<ENAME>JAMES</ENAME>
<JOB>CLERK</JOB>
<MGR>7698</MGR>
<HIREDATE>03-DEC-81</HIREDATE>
<SAL>950</SAL>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7902</EMPNO>
<ENAME>FORD</ENAME>
<JOB>ANALYST</JOB>
<MGR>7566</MGR>
<HIREDATE>03-DEC-81</HIREDATE>
<SAL>3000</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7934</EMPNO>
<ENAME>MILLER</ENAME>
<JOB>CLERK</JOB>
<MGR>7782</MGR>
<HIREDATE>23-JAN-82</HIREDATE>
<SAL>1300</SAL>
<DEPTNO>10</DEPTNO>
</ROW>
</ROWSET>'));You can insert into an empty EMP2 table this way:
SQL> insert into emp2
2 select myemp.empno, myemp.ename, myemp.job, myemp.mgr,
3 to_date(myemp.hiredate,'dd-mon-yy'), myemp.sal,
4 myemp.comm, myemp.deptno
5 from tempxml x, xmltable('/ROWSET/ROW'
6 PASSING x.xml
7 COLUMNS
8 empno number PATH '/ROW/EMPNO',
9 ename varchar2(10) PATH '/ROW/ENAME',
10 job varchar2(9) PATH '/ROW/JOB',
11 mgr number PATH '/ROW/MGR',
12 hiredate varchar2(9) PATH '/ROW/HIREDATE',
13 sal number PATH '/ROW/SAL',
14 comm number PATH '/ROW/COMM',
15 deptno number PATH '/ROW/DEPTNO'
16 ) myemp;
14 rows created.
SQL> select * from emp2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.Max
http://oracleitalia.wordpress.com -
How to Convert internal table data into xml and xml data into internal tab
Hi Guys,
I have a requirement that i have to convert the internal table data into xml format and viceversa . for my requirement i came to know that i have to use Transformations concept. i done the converting the data from internal table into xml data by using standard Tranformations. My Question is
1) Can i use same Transformation to convert the xml data into abap internal table. if it is possible then how ???
2) Is it possible using the standard Transformation or I have to go for XSLT approach
Please help me out from this guys,
Thanks and Regards
KotiHi Koti,
This is possible. There is a link. With the help of this link you can convert ABAP data to XML and vice versa.
Link: http://www.heidoc.net/joomla/index.php?option=com_content&view=article&id=15:sapxslt&catid=22:sap-xslt&Itemid=31 -
Hi Friends,
See the followong code which converts xml data into itab.
*& Report ZTEST_XML1 *
REPORT ZTEST_XML1 .
*PURPOSE: This program transfers XML data into SAP internal table format
*The nodes in DOM can be stored as fields in SAP Internal table
type pool definitions
TYPE-POOLS: ixml. "iXML Library Types
type definitions
TYPES: BEGIN OF t_xml_line, "Structure for holding XML data
data(256) TYPE x,
END OF t_xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_parser TYPE REF TO if_ixml_parser,
l_istream TYPE REF TO if_ixml_istream,
l_document TYPE REF TO if_ixml_document,
l_node TYPE REF TO if_ixml_node,
l_xmldata TYPE string.
DATA: l_elem TYPE REF TO if_ixml_element,
l_root_node TYPE REF TO if_ixml_node,
l_next_node TYPE REF TO if_ixml_node,
l_name TYPE string,
l_iterator TYPE REF TO if_ixml_node_iterator.
DATA: l_xml_table TYPE TABLE OF t_xml_line, " XML Table of the structure
*t_xml_line
l_xml_line TYPE t_xml_line, " Record of structure t_xml_line
l_xml_table_size TYPE i. " XML table size
DATA: l_filename TYPE string. " String to hold filename
data: begin of i_final occurs 0,
pnumber(20),
pname(50),
pdes(70),
end of i_final.
PARAMETERS: pa_file TYPE char1024 DEFAULT 'C:\product.xml'.
Validation of XML file: Only DTD included in XML document is supported
PARAMETERS: pa_val TYPE char1 AS CHECKBOX.
start of selection
START-OF-SELECTION.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
Wrap the table containing the file into a stream.
l_istream = l_streamfactory->create_istream_itable( table = l_xml_table
size = l_xml_table_size ).
Creating a document
l_document = l_ixml->create_document( ).
Creating a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
Validate a document
IF pa_val = 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
ENDIF.
Parse the stream
IF l_parser->parse( ) <> 0.
IF l_parser->num_errors( ) <> 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
PERFORM process_dom USING l_document.
ENDIF.
*& Form get_xml_table
text
<--P_L_XML_TABLE_SIZE text
<--P_L_XML_TABLE text
FORM get_xml_table CHANGING p_l_xml_table_size
p_l_xml_table.
Local variable declarations
DATA: l_len TYPE i,
l_len2 TYPE i,
l_tab TYPE tsfixml,
l_content TYPE string,
l_str1 TYPE string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab TYPE TABLE OF string.
l_filename = pa_file.
Upload file from the client's workstation
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
filetype = 'BIN'
IMPORTING
filelength = l_xml_table_size
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data replacement
= space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
ENDFORM. " get_xml_table
*& Form process_dom
text
-->P_L_DOCUMENT text
FORM process_dom USING document TYPE REF TO if_ixml_document.
DATA: node TYPE REF TO if_ixml_node,
iterator TYPE REF TO if_ixml_node_iterator,
nodemap TYPE REF TO if_ixml_named_node_map,
attr TYPE REF TO if_ixml_node,
name TYPE string,
prefix TYPE string,
value TYPE string,
indent TYPE i,
count TYPE i,
index TYPE i.
node ?= document.
CHECK NOT node IS INITIAL.
ULINE.
WRITE:/.
WRITE: /' DOM-TREE'.
WRITE: /.
IF node IS INITIAL.
EXIT.
ENDIF.
Create a node iterator
iterator = node->create_iterator( ).
Get current node
node = iterator->get_next( ).
Loop over all nodes
WHILE NOT node IS INITIAL.
indent = node->get_height( ) * 2.
indent = indent + 20.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WRITE: / 'ELEMENT :'.
WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
IF NOT nodemap IS INITIAL.
attributes
count = nodemap->get_length( ).
DO count TIMES.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
WRITE: / 'ATTRIBUTE:'.
WRITE: AT indent name COLOR COL_HEADING INVERSE, '=',
value COLOR COL_TOTAL INVERSE.
ENDDO.
ENDIF.
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
text node
value = node->get_value( ).
WRITE: / 'VALUE :'.
WRITE: AT indent value COLOR COL_GROUP INVERSE.
ENDCASE.
Advance to next node
node = iterator->get_next( ).
ENDWHILE.
*delete adjacent duplicates from i_final.
*loop at i_final.
*write:/ i_final-pnumber,i_final-pname,i_final-pdes.
*endloop.
*if not i_final[] is initial.
*modify ztestproduct from table i_final.
*endif.
ENDFORM. " process_dom
in the above code at line no: 268 there is a method:
value = node->get_value( ).in which actual data from XML file is coming.
So the varibale "Value" contains the data.
see line no: 270:
WRITE: AT indent value COLOR COL_GROUP INVERSE.
what ever values i am getting here i want to append to a Internal table ...
Can any body tell me how to do that?
i am sure of reward points.Hai Ravi
REPORT abc.
DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
FIRST PHASE
FIRST PHASE
FIRST PHASE
Fetch Data
SELECT * FROM t001 INTO TABLE t001.
XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
Convert to TABLE
CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'
EXPORTING
i_string = xml_out
i_tabline_length = 100
TABLES
et_table = itab.
Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:\xx.xml'
TABLES
data_tab = itab.
SECOND PHASE
SECOND PHASE
SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[].
Regards
Sreeni -
Hi,
I need to load the xml data into the relational tables. I was trying to use a DOM parser, but the thing is that i had to hard code the element node values to match the columns in the tables, and in later stage if there is change to the xml i have to change my program and recompile, i want a more flexible solution, where in i can parse the data and load into database without much changes. I do not know how to accomplish this. I have searched on this topic, but could not find a clear solution anywhere. Can anybody suggest a solution to this.
Thanks & regards.For which database?
With the Oracle database an XML document may be stored in a database with the XML SQL (XSU) utility.
1. Create a table in the database with columns corresponding to the elements in the XML document.
2. With the XSU store the XML document. The attributes in the XML document do not get stored.
3. To store the attributes also, apply an XSLT to the XML document and convert the attributes to elements. -
Loading XML Data into Relational Table
Hello,
I receive an XML file generated from another tool (on Windows), I am trying to create a Linux shell script that will gather the needed XML file from my Linux database server, then have Oracle use this file to load the XML data into a relational table. This activity & data will be needed on an ongoing basis.
I have tried this two ways. First, I loaded the XML document into the database and tried to extract the data directly from the document, but that is not working. Now I want to try to read the data directly from the file on the server via select, however I am not getting any data returned. In the Select statement below, I am simply trying to query the data to see what is returned for my testing.
Create Table ci_results_table (transactionID Varchar2(100), //transactionID should be PrimaryKey but was getting NULL value errors during insert test, so removed PK
message Varchar2(200),
ci Varchar2(50),
processeddate xmltype,
status Varchar2(50),
sourcefile VarChar2(100));
select x.*
from XMLTable(
'TSPLoadResults/Results'
PASSING xmltype(bfilename('CMDB_DEVADHOCRESULTS_DIR','LoadResults-HP_146.results.xml'), nls_charset_id('AL32UTF8'))
COLUMNS
transactionID Varchar2(100) PATH 'TransactionID',
Result XMLType PATH 'Result',
Message Varchar2(200) PATH 'Message',
PrimaryKey Varchar2(50) PATH 'PrimaryKey',
ProcessedDate date PATH 'ProcessedDate',
Status Varchar2(50) PATH 'Status',
SourceFile VarChar2(100) PATH 'SourceFileName'
) x
Eventually I will need to build on this to limit the data returned to those records where SourceFileName is like 'HPDS%' and insert what is returned in to the ci_results_table. Attached is a sample Results XML file I am trying to load, It is named "ResultsTransformedtoUnix" because I used dos2Unix to convert it to Unix which may be right or wrong. (The output file I send out has to be transformed to DOS format before the other application can read it). Original file (before Unix conversion) named in script is also attached.
Please help. Thank you!Hi,
I see some wrong things in your query.
1) The obvious one, explaining why you're not getting any data : there's a typo in the XQuery expression, it's "Result" not "Results"
2) ProcessedDate cannot be extracted as a date (at least not directly) since it actually represents a timestamp, use TIMESTAMP WITH TIME ZONE datatype and cast back to DATE in the SELECT clause
3) transactionID is an attribute, it must be accessed with '@' (or 'attribute::' axis)
4) If the file encoding is truly ISO-8859-1 as the prolog suggests, then do not use AL32UTF8 but the corresponding charset name : WE8ISO8859P1
Here's the working query :
select x.transactionID
, x.Message
, x.Primarykey
, cast(x.ProcessedDate as date) ProcessDate
, x.Status
, x.SourceFile
from XMLTable(
'/TSPLoadResults/Result'
PASSING xmltype(bfilename('XML_DIR','LoadResults-HP_146.results.xml'), nls_charset_id('WE8ISO8859P1'))
COLUMNS
transactionID Varchar2(100) PATH '@transactionID',
Message Varchar2(200) PATH 'Message',
PrimaryKey Varchar2(50) PATH 'PrimaryKey',
ProcessedDate timestamp with time zone PATH 'ProcessedDate',
Status Varchar2(50) PATH 'Status',
SourceFile VarChar2(100) PATH 'SourceFileName'
) x
Using this query directly over the file will only perform decently (for large files) on 11.2.0.4 and onwards.
On prior versions, first load the file in a (temporary) XMLType column with Binary XML storage and SELECT from there.
because I used dos2Unix to convert it to Unix which may be right or wrong.
This conversion shouldn't be necessary. -
Exporting form data to a single table
I have created a form in LiveCycle Designer ES 8.2 and simply want to export the data into a single table that I can then import into Access. It appears that in LiveCycle the row elements of a table are children of the table element and the column elements are children of the row elements. I am wondering if there is an easy way to design a form in LiveCycle so that each cell of a table is a root element like the rest of the fields in the form. I basically want to export one row of data from each form and append it to a larger table. Exporting the data as csv or tab-delimited would be sufficient, but neither of these appears to be an option.
The only way I've found to do this is to open the form in Acrobat, click Forms, mouse over Manage Form Data, then click Export Data. Your only options are to save as .xml or .xdp. I saved my data as .xml. I was then able to import the .xml file into excel by clicking Data, mousing over xml, clicking Import... and browsing to the Acrobat generated .xml file. I know this is convoluted but it's the only way I've found to get the data into a spreadsheet. Acrobat exports the data as filename_data.xml, i.e. a form named contacts will export it's data as contacts_data.xml. Be aware, I've only tested this on a form that had a table in it and nothing else. If your table is part of a form with other fields in it I have no idea how the other data will look after exporting.
-
How to insert more than 32k xml data into oracle clob column
how to insert more than 32k xml data into oracle clob column.
xml data is coming from java front end
if we cannot use clob than what are the different options availableAre you facing any issue with my code?
String lateral size error will come when you try to insert the full xml in string format.
public static boolean writeCLOBData(String tableName, String id, String columnName, String strContents) throws DataAccessException{
boolean isUpdated = true;
Connection connection = null;
try {
connection = ConnectionManager.getConnection ();
//connection.setAutoCommit ( false );
PreparedStatement PREPARE_STATEMENT = null;
String sqlQuery = "UPDATE " + tableName + " SET " + columnName + " = ? WHERE ID =" + id;
PREPARE_STATEMENT = connection.prepareStatement ( sqlQuery );
// converting string to reader stream
Reader reader = new StringReader ( strContents );
PREPARE_STATEMENT.setClob ( 1, reader );
// return false after updating the clob data to DB
isUpdated = PREPARE_STATEMENT.execute ();
PREPARE_STATEMENT.close ();
} catch ( SQLException e ) {
e.printStackTrace ();
finally{
return isUpdated;
Try this JAVA code. -
How to parse xml data into java component
hi
everybody.
i am new with XML, and i am trying to parse xml data into a java application.
can anybody guide me how to do it.
the following is my file.
//MyLogin.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
class MyLogin extends JFrame implements ActionListener
JFrame loginframe;
JLabel labelname;
JLabel labelpassword;
JTextField textname;
JPasswordField textpassword;
JButton okbutton;
String name = "";
FileOutputStream out;
PrintStream p;
Date date;
GregorianCalendar gcal;
GridBagLayout gl;
GridBagConstraints gbc;
public MyLogin()
loginframe = new JFrame("Login");
gl = new GridBagLayout();
gbc = new GridBagConstraints();
labelname = new JLabel("User");
labelpassword = new JLabel("Password");
textname = new JTextField("",9);
textpassword = new JPasswordField(5);
okbutton = new JButton("OK");
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 1;
gbc.gridy = 5;
gl.setConstraints(labelname,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 2;
gbc.gridy = 5;
gl.setConstraints(textname,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 1;
gbc.gridy = 10;
gl.setConstraints(labelpassword,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 2;
gbc.gridy = 10;
gl.setConstraints(textpassword,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 1;
gbc.gridy = 15;
gl.setConstraints(okbutton,gbc);
Container contentpane = getContentPane();
loginframe.setContentPane(contentpane);
contentpane.setLayout(gl);
contentpane.add(labelname);
contentpane.add(labelpassword);
contentpane.add(textname);
contentpane.add(textpassword);
contentpane.add(okbutton);
okbutton.addActionListener(this);
loginframe.setSize(300,300);
loginframe.setVisible(true);
public static void main(String a[])
new MyLogin();
public void reset()
textname.setText("");
textpassword.setText("");
public void run()
try
String text = textname.getText();
String blank="";
if(text.equals(blank))
System.out.println("First Enter a UserName");
else
if(text != blank)
date = new Date();
gcal = new GregorianCalendar();
gcal.setTime(date);
out = new FileOutputStream("log.txt",true);
p = new PrintStream( out );
name = textname.getText();
String entry = "UserName:- " + name + " Logged in:- " + gcal.get(Calendar.HOUR) + ":" + gcal.get(Calendar.MINUTE) + " Date:- " + gcal.get(Calendar.DATE) + "/" + gcal.get(Calendar.MONTH) + "/" + gcal.get(Calendar.YEAR);
p.println(entry);
System.out.println("Record Saved");
reset();
p.close();
catch (IOException e)
System.err.println("Error writing to file");
public void actionPerformed(ActionEvent ae)
String str = ae.getActionCommand();
if(str.equals("OK"))
run();
//loginframe.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}hi, thanks for ur reply.
i visited that url, i was able to know much about xml.
so now my requirement is DOM.
but i dont know how to code in my existing file.
means i want to know what to link all my textfield to xml file.
can u please help me out. i am confused.
waiting for ur reply -
Loading new xml data into a already xml populated image display
Hi everybody,
I have a question about loading new xml data into a already xml populated image gallery.
So I have my gallery set up so it calls some xml when it first loads. What I would now like to do is load different sets of images via a different xml sheet via the click of a button.
So for example the loaded gallery already has all thumbs loaded and user can click on them to view the full size image. So next instead of the user having to close this gallery to allow a new gallery to open with a different set of pictures I would just like to have a button. This button will unload the existing thumbs from the gallery and load in new ones from a different xml file.
If anybody can help me with this it would be great as I am still on a steep learning curve with AS3.
Here is my AS3
var xmlPath:String = "pictures.xml";
var xml:XML;
var loader = new URLLoader();
loader.load(new URLRequest(xmlPath));
loader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(e:Event):void
if ((e.target as URLLoader) != null )
xml = new XML(loader.data);
createMenu();
var numberOfItems:uint = 0;
var menuItems:Array = new Array();
function createMenu():void
numberOfItems = xml.items.item.length();
var count:uint = 0;
for each (var item:XML in xml.items.item)
var imageLoader=new Loader();
var menuItem:MenuItem = new MenuItem();
menuItem.addChild(imageLoader);
imageLoader.load(new URLRequest(item.url));
menuItem.linkTo = item.linkTo;
menuItem.mouseChildren = false;
menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
menuItems.push(menuItem);
addChild(menuItem);
count++;
function ***():void
//menuItems.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);
for (var i:uint = 0; i < menuItems.length; i++)
setChildIndex(menuItems[i], i);Thanks so much for the reply Andrei1
I think maybe my lack of knowledge when it comes to AS3 is not helping me at the moment because I thought I understood the code you supplied but there is something not going quite right.
So I messed around with the code and added the new_loaded_thumbs_btn to load in the "new_pictures.xml" but I am def doing something wrong.
import flash.ui.ContextMenuItem;
var xmlPath:String = "pictures.xml";
var xml:XML;
var numberOfItems:uint = 0;
var menuItems:Array = new Array();
var loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, xmlLoaded);
loadXML("pictures.xml");
new_loaded_thumbs_btn.addEventListener(MouseEvent.CLICK, loadXML);
function loadXML(path:String):void {
loader.load(new URLRequest("new_pictures.xml"));
function loadXML(path:String):void {
loader.load(new URLRequest(path));
function xmlLoaded(e:Event):void
xml = new XML(loader.data);
createMenu();
function createMenu():void
clearMenu();
numberOfItems = xml.items.item.length();
var count:uint = 0;
var imageLoader;
var menuItem:MenuItem;
for each (var item:XML in xml.items.item)
imageLoader = Loader();
menuItem = new MenuItem();
menuItem.addChild(imageLoader);
imageLoader.load(new URLRequest(item.url));
menuItem.linkTo = item.linkTo;
menuItem.mouseChildren = false;
menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
menuItems.push(menuItem);
addChild(menuItem);
count++;
sortChildren();
// removes previously placed objects
function clearMenu():void {
var menuItem:MenuItem;
while (menuItems.length > 0) {
menuItem = menuItems[0];
removeChildAt(getChildIndex(menuItem));
menuItem.shift();
function sortChildren():void
//menuItems.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);
for (var i:uint = 0; i < menuItems.length; i++)
setChildIndex(menuItems[i], i);
When the image display 1st loads it displays the new_pictures.xml thumbs which I thought would load through my new button when clicked.
And there was me thinking I was getting the hang of AS3.
Could you please point me in the right direction in what I am doing wrong,
Thanks for your time and effort in advance -
How to store xml data into file in xml format through java program?
HI Friends,
Please let me know
How to store xml data into file in xml format through java program?
thanks......
can discuss further at messenger.....
Avanish Kumar Singh
Software Engineer,
Samsung India Development Center,
Bangalore--560001.
[email protected]Hi i need to write the data from an XML file to a Microsoft SQL SErver database!
i got a piece of code from the net which allows me to parse th file:
import java.io.IOException;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import org.apache.xerces.parsers.SAXParser;
import java.lang.*;
public class MySaxParser extends DefaultHandler
private static int INDENT = 4;
private static String attList = "";
public static void main(String[] argv)
if (argv.length != 1)
System.out.println("Usage: java MySaxParser [URI]");
System.exit(0);
String uri = argv[0];
try
XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
MySaxParser MySaxParserInstance = new MySaxParser();
parser.setContentHandler(MySaxParserInstance);
parser.parse(uri);
catch(IOException ioe)
ioe.printStackTrace();
catch(SAXException saxe)
saxe.printStackTrace();
private int idx = 0;
public void characters(char[] ch, int start, int length)
throws SAXException
String s = new String(ch, start, length);
if (ch[0] == '\n')
return;
System.out.println(getIndent() + " Value: " + s);
public void endDocument() throws SAXException
idx -= INDENT;
public void endElement(String uri, String localName, String qName) throws SAXException
if (!attList.equals(""))
System.out.println(getIndent() + " Attributes: " + attList);
attList = "";
System.out.println(getIndent() + "end document");
idx -= INDENT;
public void startDocument() throws SAXException
idx += INDENT;
public void startElement(String uri,
String localName,
String qName,
Attributes attributes) throws SAXException
idx += INDENT;
System.out.println('\n' + getIndent() + "start element: " + localName);
if (localName.compareTo("Machine") == 0)
System.out.println("YES");
if (attributes.getLength() > 0)
idx += INDENT;
for (int i = 0; i < attributes.getLength(); i++)
attList = attList + attributes.getLocalName(i) + " = " + attributes.getValue(i);
if (i < (attributes.getLength() - 1))
attList = attList + ", ";
idx-= INDENT;
private String getIndent()
StringBuffer sb = new StringBuffer();
for (int i = 0; i < idx; i++)
sb.append(" ");
return sb.toString();
}// END PRGM
Now , am not a very good Java DEv. and i need to find a soln. to this prob within 1 week.
The next step is to write the data to the DB.
Am sending an example of my file:
<Start>
<Machine>
<Hostname> IPCServer </Hostname>
<HostID> 80c04499 </HostID>
<MachineType> sun4u [ID 466748 kern.info] Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 360MHz) </MachineType>
<CPU> UltraSPARC-IIi at 360 MHz </CPU>
<Memory> RAM : 512 MB </Memory>
<HostAdapter>
<HA> kern.info] </HA>
</HostAdapter>
<Harddisks>
<HD>
<HD1> c0t0d0 ctrl kern.info] target 0 lun 0 </HD1>
<HD2> ST38420A 8.2 GB </HD2>
</HD>
</Harddisks>
<GraphicCard> m64B : PCI PGX 8-bit +Accel. </GraphicCard>
<NetworkType> hme0 : Fast-Ethernet </NetworkType>
<EthernetAddress> 09:00:30:C1:34:90 </EthernetAddress>
<IPAddress> 149.51.23.140 </IPAddress>
</Machine>
</Start>
Note that i can have more than 1 machines (meaning that i have to loop thru the file to be able to write to the DB)
Cal u tellme what to do!
Even better- do u have a piece of code that will help me understand and implement the database writing portion?
I badly need help here.
THANX
Maybe you are looking for
-
I have a PC. I would like to sync my iPad2 via itunes. My computer recognizes my ipad but itunes does not. I have uninstalled itunes, shut down the computer and restarted plus reinstalled itunes. I visited the Apple store there is no problem with
-
Media encoder in BG is pausing
I'm running media encoder in the background exporting clips from a timeline. I'm adding more clips to this timeline and as I do so it's causing the MC to pause. Is this normal? I would think that it would be possible to render in the BG while work
-
I put in my SIM card and then it says so service, what do i do?
Everytime that i put in my sim card, it says no service. I can't call anyone or access my voice mail. I live in Trinidad so i don't have an apple store to go to. It was working perfectly fine until i updated my phone. My service carrier is Digicel bu
-
Mac Indesign Spotlight no results for finding files
Hel I'm in inDesign, I go to "Open" a new file. Type in to search for it and NOTHING comes up.o to If I go to finder, directly, it finds it snap-and-pop.! Thanks!!
-
PSE8 Organizer won't display on monitor
I have a really strange problem. I have a new laptop running Windows 7. I have a mouse, keyboard and monitor (among other things) attached to it via a port replicator so I can use the laptop as a desktop (whatever happened to good old docking stati