How to extract xml comments
Hi,
I have loaded XML files into my table of XML Type . I have comments in XML file. This comments are important to us and I want to extract this comments . How can we extract the comments present in XML file. I was not able to find any function which can do it.
Thanks,
Ramesh.
Hi Ramesh,
First of all, instead of posting three times in different forums, why not provide relevant details such as database version and a sample XML?
Generally, XML comments are not meant to be extracted.
If they contain so important data then most likely that data should be stored in regular element or attribute nodes.
Here's an example using XQuery though :
SQL> create table tmp_xml of xmltype;
Table created
SQL>
SQL> insert into tmp_xml values (
2 xmltype('<root>
3 <!-- this is a comment -->
4 <item/>
5 <!-- this is another comment -->
6 </root>')
7 );
1 row inserted
SQL>
SQL> select x.comment_text
2 from tmp_xml t
3 , xmltable(
4 '/descendant::comment()'
5 passing t.object_value
6 columns comment_text varchar2(200) path '.'
7 ) x
8 ;
COMMENT_TEXT
this is a comment
this is another comment
Similar Messages
-
How to preserve XML comments in indesign cs4 document
Hi,
I have the below table xml with me:
<?xml version="1.0" encoding="UTF-8"?>
<informaltable xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid5:tablestyle="UNTABLE" aid:trows="4" aid:tcols="2" float="0">
<!--tgroup aid:table="table" aid5:tablestyle="UNTABLE" aid:trows="24" cols="2" colsep="0" rowsep="0" align="left"--><!--colspec colnum="1" colname="c1" align="left" colwidth="25"/--><!--colspec colnum="2" colname="c2" align="left" colwidth="25"/--><!--thead--><Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="129" valign="top"><para aid:pstyle="CR_H1">Chronology:</para></Cell><Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="129" valign="top"><para aid:pstyle="CR_H1">14,000 Years Ago to 1590 c.e.</para></Cell>
<!--/thead--><!--tbody--><Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="129" valign="top"><para aid:pstyle="CR_UNTBL"><emphasis aid:cstyle="BOLD" role="strong">14,000 years ago</emphasis></para></Cell><Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="129" valign="top"><para aid:pstyle="CR_UNTBL">Early Paleo-Indians in Florida and Pennsylvania regions, and also in Monte Verde, Chile.</para></Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="129" valign="top"><para aid:pstyle="CR_UNTBL"><emphasis aid:cstyle="BOLD" role="strong">13,900 to 12,900</emphasis></para></Cell><Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="129" valign="top"><para aid:pstyle="CR_UNTBL">Clovis hunters spread</para></Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="129" valign="top"><para aid:pstyle="CR_UNTBL"><emphasis aid:cstyle="BOLD" role="strong">years ago</emphasis></para></Cell><Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="129" valign="top"><para aid:pstyle="CR_UNTBL">across North America.</para></Cell>
<!--/tbody--><!--/tgroup--></informaltable>
I am able to import this xml in to indeisgn document successfully. But when I export the same table out of Indesign, the xml comment <!--tgroup... is not exported.
Is there any method to preserve the comment on export. Please suggest a solution for this.
Thanks,
GopalYou must include the comment() as one of the elements that you select to process.
It is best to use xsl:value-of or xsl:copy-of with select="informaltable/comment()" to avoid processing comments from other parts of your XML file. In other words, always make the processing of comment() specific to the location where you need to extract the content of the comment. -
<ROOT>
<TEST>
<TESTING>
<ROW1>1</ROW1>
<ROW2>2</ROW2>
<ROW3>3</ROW3>
</TESTING>
</TEST>
</ROOT>
How to extract the xml as this output ,above xml will come as parameter.
I can achieve it is stored in table i can able to get by using xpath.
As parameter i cant able to do it.Kindly help.
SELECT extract(xmldata,'/ROOT/TEST/TESTING')
FROM EAPP
I can get this output if that xml is stored in xml.
But my requiremnet is before storing i want to eliminate root tag and test tag and i want to insert.
as below example
<TESTING>
<ROW1>1</ROW1>
<ROW2>2</ROW2>
<ROW3>3</ROW3>
</TESTING>
SELECT VALUE(p)
FROM
TABLE(XMLSEQUENCE(EXTRACT(xmldata, '/ROOT/*'))) p
but it is not working .
Edited by: LRAJESH on Oct 22, 2010 1:21 AMYou mentioned a parameter so I'm going to assume you are doing the processing in PL/SQL.
One approach would be to use method 4 at
http://anononxml.blogspot.com/2010/05/one-question-that-comes-up-with-some.html
and leave the /text() off of the end of the XPath. As the first Gotcha lists, this will return an XML fragment containing all the nodes you want.
You can still parse the XML in a SQL statement as you are trying to do. Just replace the table.column reference with your PL/SQL variable.
If you are on 10.2.x.x or greater, look into using XMLTable instead of TABLE(XMLSEQUENCE(EXTRACT(...))) For the COLUMN, you would want to return an XMLType.
Yes I'm being a bit vague on purpose. There are lots of examples on the forums already. Still don't know what version of Oracle you are using either. -
How to extract xml tag name contains dashes
Hi, How to parse XML file to extract root tag contains dashes in Flex,for example
XML Input is: <regular-body>Text of my post...</regular-body>
expected output is : regular-body
I appreciate any of your suggestions or inputsDo you want to get the name of the XML ELEMENT regular-body, or the value in the XML file "Text of my post...".
If its the latter, then you could use the bracket/quote notation for extracting the value, like in the following example:
image = xmlWeather[0]..parameters["conditions-icon"]["icon-link"][idx]
I use this when parsing weather information from a 3rd party in which their XML is loaded with dashes.
If you are looking to get the actual element name, not sure how to do that. I would think that if you are using an XML file, you would have at least the high level element known. -
How to extract XML from EAR file?
how to Extract weblogic-application.xml file from StellentPortlets.ear file ???
http://en.wikipedia.org/wiki/EAR_(file_format)
An EAR file is a standard JAR file (and therefore a Zip file) with a .ear extension, with one or more entries representing the modules of the application, and a metadata directory called META-INF which contains one or more deployment descriptors.
7zip is a nice tool for me but most any should be usable. -
How to extract xml having namespaces
Hi all,
Below is the XML i have :
<?xml version="1.0" encoding="UTF-8" ?>
- <Transaction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.test.com/Support/Services/test1/2012" xsi:schemaLocation="http://schemas.test.com/Support/Services/test1/2012 Support.test1.v1.xsd">
- <Request>
<Memid>10</Memid>
<Actid>32</Actid>
<Pax>3</Pax>
<Flt>2012-DEC-10</Flt>
<Username>WebUserNameTest</Username>
</Request>
<Request>
<Memid>1</Memid>
<Actid>3</Actid>
<Pax>2</Pax>
<Flt>2012-DEC-12</Flt>
<Username>WebUserNameTest</Username>
</Request>
</Transaction>
I want to extract the element values :
The below code will help me when i have no namespace , what must be done in order to work with namespace and etract element value
v_string_xml :=
' //Request[' || TO_CHAR (counter_xml) || ']/Memid/text()';
v_ssp_table (v_ssp_table.COUNT).memid :=
p_xml_in.EXTRACT (v_string_xml).getnumberval ();
v_string_xml :=
'//Request[' || TO_CHAR (counter_xml) || ']/Actid/text()';
v_ssp_table (v_ssp_table.COUNT).actid :=
p_xml_in.EXTRACT (v_string_xml).getnumberval ();
v_string_xml :=
'//Request['
|| TO_CHAR (counter_xml)
|| ']/Pax/text()';
v_ssp_table (v_ssp_table.COUNT).pax :=
p_xml_in.EXTRACT (v_string_xml).getnumberval ();
v_string_xml :=
'//Request[' || TO_CHAR (counter_xml) || ']/Flt/text()';
v_ssp_table (v_ssp_table.COUNT).flt :=
p_xml_in.EXTRACT (v_string_xml).getstringval ();
v_string_xml :=
'//Request['
|| TO_CHAR (counter_xml)
|| ']/Username/text()';
v_ssp_table (v_ssp_table.COUNT).username :=
p_xml_in.EXTRACT (v_string_xml).getstringval ();
Edited by: akm006 on Mar 19, 2013 11:11 AModie_63 wrote:
AlexAnd wrote:
28 v_string_xml_ns :='xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.test.com/Support/Services/test1/2012"';
You can remove the xsi prefix, no need to make it more verbose than it already is ;)misunderstood
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as scott
SQL>
begin
v_string_xml := 'Transaction/Request[' || TO_CHAR (counter_xml) || ']/Memid/text()';
--v_string_xml_ns :='xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.test.com/Support/Services/test1/2012"';
v_string_xml_ns :='xmlns="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.test.com/Support/Services/test1/2012"';
v_ssp := x.EXTRACT(v_string_xml,v_string_xml_ns).getnumberval();
dbms_output.put_line(v_ssp);
end;
ORA-30625: method dispatch on NULL SELF argument is disallowed
ORA-06512: at line 33
SQL>
24 begin
25
26 v_string_xml := 'Transaction/Request[' || TO_CHAR (counter_xml) || ']/Memid/text()';
27
28 --v_string_xml_ns :='xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.test.com/Support/Services/test1/2012"';
29 v_string_xml_ns :='xmlns="http://schemas.test.com/Support/Services/test1/2012"';
30
31
32 v_ssp := x.EXTRACT(v_string_xml,v_string_xml_ns).getnumberval();
33
34 dbms_output.put_line(v_ssp);
35
36 end;
37 /
1
PL/SQL procedure successfully completed
SQL> so for no xsi namespace it's work for above case
and for "xsi prefix" doesnt' work
or i missed anything?
2 akm006
So do you have any suggestion on the same.i can't test -
How to extract XML with namespace?
Hi all,
Below is the XML i have :
<?xml version="1.0" encoding="UTF-8" ?>
- <Transaction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.test.com/Support/Services/test1/2012" xsi:schemaLocation="http://schemas.test.com/Support/Services/test1/2012 Support.test1.v1.xsd">
- <Request>
<Memid>10</Memid>
<Actid>32</Actid>
<Pax>3</Pax>
<Flt>2012-DEC-10</Flt>
<Username>WebUserNameTest</Username>
</Request>
<Request>
<Memid>1</Memid>
<Actid>3</Actid>
<Pax>2</Pax>
<Flt>2012-DEC-12</Flt>
<Username>WebUserNameTest</Username>
</Request>
</Transaction>
I want to extract the element values :
The below code will help me when i have no namespace , what must be done in order to work with namespace and etract element value
v_string_xml :=
' //Request[' || TO_CHAR (counter_xml) || ']/Memid/text()';
v_ssp_table (v_ssp_table.COUNT).memid :=
p_xml_in.EXTRACT (v_string_xml).getnumberval ();
v_string_xml :=
'//Request[' || TO_CHAR (counter_xml) || ']/Actid/text()';
v_ssp_table (v_ssp_table.COUNT).actid :=
p_xml_in.EXTRACT (v_string_xml).getnumberval ();
v_string_xml :=
'//Request['
|| TO_CHAR (counter_xml)
|| ']/Pax/text()';
v_ssp_table (v_ssp_table.COUNT).pax :=
p_xml_in.EXTRACT (v_string_xml).getnumberval ();
v_string_xml :=
'//Request[' || TO_CHAR (counter_xml) || ']/Flt/text()';
v_ssp_table (v_ssp_table.COUNT).flt :=
p_xml_in.EXTRACT (v_string_xml).getstringval ();
v_string_xml :=
'//Request['
|| TO_CHAR (counter_xml)
|| ']/Username/text()';
v_ssp_table (v_ssp_table.COUNT).username :=
p_xml_in.EXTRACT (v_string_xml).getstringval ();declare
v_xml xmltype := xmltype( '<?xml version="1.0" encoding="UTF-8" ?>
<Transaction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.test.com/Support/Services/test1/2012" xsi:schemaLocation="http://schemas.test.com/Support/Services/test1/2012 Support.test1.v1.xsd">
<Request>
<Memid>10</Memid>
<Actid>32</Actid>
<Pax>3</Pax>
<Flt>2012-DEC-10</Flt>
<Username>WebUserNameTest</Username>
</Request>
<Request>
<Memid>1</Memid>
<Actid>3</Actid>
<Pax>2</Pax>
<Flt>2012-DEC-12</Flt>
<Username>WebUserNameTest</Username>
</Request>
</Transaction>' );
begin
for r_xml in ( select *
from xmltable( xmlnamespaces( default 'http://schemas.test.com/Support/Services/test1/2012' )
, '/Transaction/Request'
passing v_xml
columns memid number path 'Memid'
, actid number path 'Actid'
, pax number path 'Pax'
, flt varchar2(100) path 'Flt'
, username varchar2(100) path 'Username'
loop
dbms_output.put_line( r_xml.memid );
dbms_output.put_line( r_xml.actid );
dbms_output.put_line( r_xml.pax );
dbms_output.put_line( r_xml.flt );
dbms_output.put_line( r_xml.username );
end loop;
end; -
How to extract the actual XML document from soap message?
My problem is " how to extract the actual XML document from soap message? "
i just want to extract the attachment i.e. (pure XML document without any soap header or envolope).
i could be ver thank full if u could solve my problem.
[email protected]Hi,
This is some skeleton code for extracting an attachment from a SOAPMessage.
import javax.activation.DataHandler.;
import javax.xml.soap.*;
import javax.xml.message.*;
Iterator allAttachments = message.getAttachments();
AttachmentPart ap1 = null;
while(allAttachments.hasNext()){
ap1 = (AttachmentPart)allAttachments.next();
//Check that the attachment is correct one. By looking at its mime headers
//Convert the attachment part into its DOM representation:
if(ap1.getContentType() == "text/xml"){
//Use the activation dataHandler class to extract the content, then create a StreamSource from
//the content.
DataHandler attachmentContent = ap1.getDataHandler();
StreamSource attachmentStream = new StreamSource(attachmentContent.getInputStream());
DOMResult domAttachment = getDOMResult(attachmentStream);
domAttachment holds an xml representation of the attachment.
Hope this helps. -
How to extract data from XML file with JavaScript
HI All
I am new to this group.
Can anybody help me regarding XML.
I want to know How to extract data from XML file with JavaScript.
And also how to use API for XML
regards
NagarajuThis is a Java forum.
JavaScript is something entirely different than Java, even though the names are similar.
Try another website with forums about JavaScript.
For example here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3 -
How to extract a clob xml string with multiple row of table tag. in 10g
i have a xml value like:
<table><c1>0</c1><c2>Mr</c2><c3>abc</c3><c4>Sharma</c4></table>
<table><c1>0</c1><c2>Mrs</c2><c3>abcd</c3><c4>Sharma</c4></table>
<table><c1>0</c1><c2>Mr</c2><c3>sabc</c3><c4>Sharma</c4></table>
<table><c1>0</c1><c2>Mrs</c2><c3>sdabc</c3><c4>Sharma</c4></table>
<table><c1>0</c1><c2>Mr</c2><c3>dabc</c3><c4>Sharma</c4></table>
<table><c1>0</c1><c2>Mr</c2><c3>adbc</c3><c4>Sharma</c4></table>
i want to insert each of <c> value in a table with respective columns according c1,c2,c3,c4
pls suggest me what to do
I use extract(xml, '/table) tab but it just read first one line & return error for otherCan you plz explain to me thisIt is because you did not provide us with a valid xml structure so I used 11g's xmlparse function to create a xmltype even with the xml not being valid (no root tag).
With a valid xml structure I could use the xmltype constructor instead and go on the same way as before:
SQL> select *
from xmltable (
'table'
passing xmltype ('
<root>
<table><c1>0</c1><c2>Mr</c2><c3>abc</c3><c4>Sharma</c4></table>
<table><c1>0</c1><c2>Mrs</c2><c3>abcd</c3><c4>Sharma</c4></table>
<table><c1>0</c1><c2>Mr</c2><c3>sabc</c3><c4>Sharma</c4></table>
<table><c1>0</c1><c2>Mrs</c2><c3>sdabc</c3><c4>Sharma</c4></table>
<table><c1>0</c1><c2>Mr</c2><c3>dabc</c3><c4>Sharma</c4></table>
<table><c1>0</c1><c2>Mr</c2><c3>adbc</c3><c4>Sharma</c4></table>
</root>').extract ('root/table')
columns c1 number path 'c1', c2 varchar2 (4) path 'c2', c3 varchar2 (6) path 'c3', c4 varchar2 (6) path 'c4')
C1 C2 C3 C4
0 Mr abc Sharma
0 Mrs abcd Sharma
0 Mr sabc Sharma
0 Mrs sdabc Sharma
0 Mr dabc Sharma
0 Mr adbc Sharma
6 rows selected. -
How to Extract particular field from a string ( Mapping)
how to exteract the particular field from the given string:
ProcessEmp this element has a below string subfields.
<ProcessEmp><?xml version="1.0" encoding="utf-8" standalone="no"?>
<Employee PersonnelNumber="11111" FirstName="String" MiddleName="String" LastName="String" Department="String" Group="" SapUserID="10flname" EmailAddress="[email protected]" DefaultPassword="*" Status="Success" /></ProcessEmp>
how to extract only PersonalNumber, department, EmailAddress from above ProcessEmp into 3 diff fields.
Thanks
dhanush.Hi,
You are receiving XML message within a field. To access a particular field from that XML message, you could create a User Defined Function, as suggested by many already.
You could write UDF using some of the String operation functions. This could include following:
1. If you need to access field Employee PersonnelNumber, you could get last index of that within string using function lastIndexOf(String str). Pass string "Employee PersonnelNumber="" for this function.
2. This function would return an index of rightmost occurance of this string.
3. after this you could get the index of next occurance of ", as the value of field is within quotes. You could use function indexOf(int ch, int fromIndex) for getting the same. You would pass Character as " and index as the one received by previous function.
4. Now you have index for starting and ending point of value string for desired field.
5. After this you could use substring(int beginIndex, int endIndex) function by passing first and second index values to retrieve the needed string, which contains value of field.
Hope this would be helful.
Thanks,
Bhavish
Reward points if comments found helpful:-) -
How to extract data from SAP in FDM 11121
I came across some documents from version 11113, says there is a SAP adapter, however ,when I check 11121 there's no such adapter, does anyone know how to extract data from SAP in FDM 11121?
I download a package from Bristlecone, but I dont see any xml files in it, just a bunch of dll and I didn't find any instructions on how to set up/configure in FDM, it just explained how to register in SAP app server and client.
Hyperion 11113 has readme on sap adapter(Hyperion Readme Template), but I cannot find the same readme file in 11121, all I can find is ERP Integration Adapter document. any idears where I can find at least a readme document? -
How to extract data from a resultset returned by SQLX query
Hi all,
I'm doing a project in which I use SQLX query to extract data and format it into xml from an object-relational database, and return it to a windows application. But when the resultset is returned, I don't know how to extract and display the data from it. The datatype of returned data might be XmlType, but i don't know how to process it..Can anyone help? It's urgent.. Thanks a lot in advance...
JoanneYou can use XMLType.extract().
-
Hi All
how do we extract SDA files.......
we started adapter development by testing sample code in 'sample_ra.jar' file, available in sample_ra.sda, and deployed on XI server. now we want to see all jar files available in 'sample_ra.sda'.
if any one already gone through adapter development have any idea, how to extract SDA file, help me out Pls .......... very urgent.
Regards
RajeshHI,
In general SDA files are to be deployed into Server using SDM.
see the below link , how to deploy
http://help.sap.com/saphelp_webas630/helpdata/en/05/4fac3e00c8b014e10000000a114084/content.htm
Also
you can unzip the file with WinZip or WinRar edit the xml configuration file and zip it back together (in ZIP format and not RAR!).
Also
how to deploy ear files from command line
Tools like zipgenius http://www.zipgenius.it/intweb/features.htm#Innovazione, Private encryptor http://www.filesweb.com/private-encryptor/ and securefile http://www.devsolutions.net/htmlpages/securefile.html should help you further.
Regards
Chilla -
how to extract war file? explain technoloby behind in war
hi
go to your dir :
jar xvf filename.warhelp, simply type jar, above baluc mention is right, jar/war/ear is like a zip file contains *.classes, images, xml , etc....
jar i hope it will help u
Maybe you are looking for
-
My experience with Tiger/new Powerbook 15", 1.67 ghz
Apple proclaims "Mac OS X v10.4 Tiger. The world’s most advanced operating system." Well, that hasn't been the case in my experience. I bought a new 15 Powerbook HR, 1.67 ghz, 1.5 gb ram, 80gb hd on 11/4/05 (from MacMall). At this point I have about
-
iMac G5 (iSight) with 10.4.11: Screen always dimmed. Starts at full bright and a second later dimms and stays like that forever. Brightness controls work normally under this circunstance. Please help !!! Please don't tell me to adjust anything on
-
Output Message from Purchasing Value Key
Hi All, Can anyone tell me how to configure the message and the output parameters for the time defined with the Purchasing Value Keys? What are the steps needed to create the message and to add an output? Any help would be greatly appreciated and ofc
-
I'm Using Windows 8.1 and I have just installed Creative Cloud Desktop but whenever I attempt to log in it then signs me out I have tried logging in and out and reinstalling but still fails to sign me in
-
Hi, My application is clustered on multiple machines. The application receives request mainly through the http protocol, and the application keeps session information of the user. I am using HttpClusterServlet