Xml Values extract
Hi All,
I have following xml.
My Requirement is I want tobe able to parse this xml, best possible/efficient way and get the Values of each of the Xml tags. Can anyone give me sample program where I be able to extract all the nodes values. Also, note there are repeating Fault tags(appearing 2 times). I want to extract those values also.
<?xml version="1.0" encoding="UTF-8"?>
<tsdEnterpriseService:EnterpriseService xmlns:CR="http://www.tsd.com/it/cr/CR" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:Customer="http://www.tsd.com/it/cr/Customer" xmlns:CRInterface="http://www.tsd.com/it/cr/CRInterface" xmlns:tsdEnterpriseService="http://www.tsd.com/it/cr/tsdEnterpriseService">
<tsdEnterpriseService:Preamble>
<tsdEnterpriseService:ServiceHeaderVersion>1</tsdEnterpriseService:ServiceHeaderVersion>
</tsdEnterpriseService:Preamble>
<tsdEnterpriseService:ServiceResponseHeader>
<tsdEnterpriseService:ServiceName>CRES_CompletenessGeoValidation</tsdEnterpriseService:ServiceName>
<tsdEnterpriseService:FuntionTypeCode>Response</tsdEnterpriseService:FuntionTypeCode>
<tsdEnterpriseService:ServiceVersion>1.0</tsdEnterpriseService:ServiceVersion>
<tsdEnterpriseService:AttemptCount>1</tsdEnterpriseService:AttemptCount>
<tsdEnterpriseService:ApplicationID>sccadmin</tsdEnterpriseService:ApplicationID>
<tsdEnterpriseService:SystemName>SCC</tsdEnterpriseService:SystemName>
<tsdEnterpriseService:Status>SUCCESS</tsdEnterpriseService:Status>
<tsdEnterpriseService:StatusMessage>COMPLETE, GEO VALID</tsdEnterpriseService:StatusMessage>
<tsdEnterpriseService:Fault>
<tsdEnterpriseService:Status>INCOMPLETE</tsdEnterpriseService:Status>
<tsdEnterpriseService:Component>COMPLETENESS</tsdEnterpriseService:Component>
<tsdEnterpriseService:Category>DATA</tsdEnterpriseService:Category>
<tsdEnterpriseService:Code>16</tsdEnterpriseService:Code>
<tsdEnterpriseService:Description>INVALID ADDRESS1</tsdEnterpriseService:Description>
</tsdEnterpriseService:Fault>
<tsdEnterpriseService:Fault>
<tsdEnterpriseService:Status>INCOMPLETE</tsdEnterpriseService:Status>
<tsdEnterpriseService:Component>COMPLETENESS</tsdEnterpriseService:Component>
<tsdEnterpriseService:Category>DATA</tsdEnterpriseService:Category>
<tsdEnterpriseService:Code>19</tsdEnterpriseService:Code>
<tsdEnterpriseService:Description>INVALID ADDRESS1</tsdEnterpriseService:Description>
</tsdEnterpriseService:Fault>
</tsdEnterpriseService:ServiceResponseHeader>
<tsdEnterpriseService:ServiceContent xsi:type="CR:CRType">
<CRInterface:CRGRIDBaseOutput>
<CRInterface:CertLevel>POST_CODE</CRInterface:CertLevel>
<Customer:Country>UNITED STATES</Customer:Country>
<Customer:Region/>
<Customer:State>CALIFORNIA</Customer:State>
<Customer:County>SANTA CLARA</Customer:County>
<Customer:City>SAN JOSE</Customer:City>
<Customer:PostalCode>95134</Customer:PostalCode>
<CRInterface:CountryCode>US</CRInterface:CountryCode>
<CRInterface:RegionCode/>
<CRInterface:StateCode>CA</CRInterface:StateCode>
<CRInterface:CountyCode/>
<CRInterface:CityCode/>
<CRInterface:ZipCode/>
</CRInterface:CRGRIDBaseOutput>
</tsdEnterpriseService:ServiceContent>
</tsdEnterpriseService:EnterpriseService>
Any Help?
thanks,
pp
Add lib/xmlparserv2.jar to Classpath.
Create a DOMParser.
DOMParser parser=new DOMParser();
Parse an XML document.
parser.parse(new FileInputStream(new File("c:/input/input.xml")));
Get the document parsed.
XMLDocument document=parser.getDocument();
Select node/nodes with XMLDocument select methods.
Similar Messages
-
Out XML element values extract
hi their
How can I out XML element the values extract and in a loop in variable and/or in an array store?
Example:
[loop]
<SA>'MS','GYM'</SA>
Values 'MS' and 'GYM' should be in variables e.g var1='MS' and var2='GYM'
[end loop]
Please, help me!!!! Urgent
thanx you for advice
kind regards
Holgercreate or replace procedure spTestXML is
xml xmltype;
test varchar2(100);
test2 xmltype;
cursor lvCur_GetAllSecGrps is
SELECT extractValue(value(asec), '/SEC_GRP/NAME') as Name
FROM table(xmlsequence(xml)) a,
table(xmlsequence(extract(value(a), '/EVENT/SEC_GRP_LIST/SEC_GRP'))) asec;
begin
xml := xmltype('<EVENT>
<SWTSUPDATE TYPE="1">
<MEMBERID>9822598</MEMBERID>
<DATETIME>Fri Jun 09 14:51:33 CDT 2006</DATETIME>
<USERID>W951FVK</USERID>
</SWTSUPDATE>
<CONTACT_HISTORY>
<USER>
<USER_ID>W951FVK</USER_ID>
<FIRST_NAME>John</FIRST_NAME>
<LAST_NAME>Givens</LAST_NAME>
</USER>
<USER>
<USER_ID>W951FNN</USER_ID>
<FIRST_NAME>Mary</FIRST_NAME>
<LAST_NAME>McNair</LAST_NAME>
</USER>
<CONSUMER>
<CONS_SEQ_NBR>1387445</CONS_SEQ_NBR>
<FIRST_NAME>SPRINGHOUSE</FIRST_NAME>
<LAST_NAME>ELLIS</LAST_NAME>
</CONSUMER>
</CONTACT_HISTORY>
<SEC_GRP_LIST>
<SEC_GRP><NAME>cspupdatecustpayee</NAME><DESCRIPTION>Add/Update/Delete CSP Customer Payees</DESCRIPTION></SEC_GRP>
<SEC_GRP><NAME>cspupdatepayment</NAME><DESCRIPTION>Add/Update/Delete CSP Payment</DESCRIPTION></SEC_GRP>
<SEC_GRP><NAME>adminreports</NAME><DESCRIPTION>Administrate Reports</DESCRIPTION></SEC_GRP>
<SEC_GRP><NAME>billopscsr</NAME><DESCRIPTION>Bill Operations CSR</DESCRIPTION></SEC_GRP>
</SEC_GRP_LIST>
</EVENT>');
if xml.existsNode('/EVENT/SEC_GRP_LIST/SEC_GRP/NAME') != 0 THEN
for lvAllSecGrps in lvCur_GetAllSecGrps loop
dbms_output.put_line('Found: '||lvAllSecGrps.Name);
end loop;
end if;
end spTestXML;gives
Found: cspupdatecustpayee
Found: cspupdatepayment
Found: adminreports
Found: billopscsrhth -
Its illegal to assign a XML value directly to the messageType variable
I was recently working in JDeveloper 11g (11.1.1.7.0) on an internal SOA project making some changes in the BPEL and noticed this message: Error(172): its illegal to assign a XML value directly to the messageType variable "InvokeFetchUpdatedUserId_FetchUpdatedUserID_InputVariable" I searched for this error message and didn't find anything. The message is somewhat explanatory but I thought I would post the fix here just in case. I modified my assign from the following: To this making sure to assign it to the underlying entity. Then it compiled just fine. Thanks, Tom
In case if you are returning multiple value or with multiple columns then you have to use record or cursor to do that operation.
satyaki>
satyaki>ed
Wrote file afiedt.buf
1 declare
2 cursor c1
3 is
4 select *
5 from emp;
6 r1 c1%rowtype;
7 begin
8 for r1 in c1
9 loop
10 dbms_output.put_line(r1.empno||' - '||r1.ename);
11 end loop;
12* end;
13 /
7521 - WARD
7654 - MARTIN
7788 - SCOTT
7839 - KING
7844 - TURNER
7876 - ADAMS
7900 - JAMES
7902 - FORD
7934 - MILLER
7566 - Smith
7698 - Glen
1 - boock
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.02
satyaki>
satyaki>
satyaki>Regards.
Satyaki De. -
How to fix iframe issue that displays XML values instead of formatted XML in IE11
The following sub.jsp file shows the formatted XML properly as expected when is opened directly:
<% response.setContentType("text/xml"); %>
<book>
<chapter1>chapter 1</chapter1>
<chapter2>chapter 2</chapter2>
</book>
IE11 shows the result as below which are colored and can be collapsed or un-collapsed:
<book><chapter1>chapter 1</chapter1><chapter2>chapter 2</chapter2></book>
But if the sub.jsp is opened in an iframe from the below main.html, it only shows the values of the XML in the iframe:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<iframe src="sub.jsp"></iframe>
</body>
</html>
The iframe shows only the XML values, i.e., chapter 1 chapter 2 in IE11. This issue does not happen in IE8.
I appreciate to your if you know how to address this issue.
Regards, AmirThe following sub.jsp file shows the formatted XML properly as expected when is opened directly:
<% response.setContentType("text/xml"); %>
<book>
<chapter1>chapter 1</chapter1>
<chapter2>chapter 2</chapter2>
</book>
IE11 shows the result as below which are colored and can be collapsed or un-collapsed:
<book><chapter1>chapter 1</chapter1><chapter2>chapter 2</chapter2></book>
But if the sub.jsp is opened in an iframe from the below main.html, it only shows the values of the XML in the iframe:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<iframe src="sub.jsp"></iframe>
</body>
</html>
The iframe shows only the XML values, i.e., chapter 1 chapter 2 in IE11. This issue does not happen in IE8.
I appreciate to your if you know how to address this issue.
This issue is also posted at below link:
https://social.msdn.microsoft.com/Forums/en-US/5b0692b4-d312-4797-9089-42c1029ac059/how-to-fix-iframe-issue-that-displays-xml-values-instead-of-formatted-xml-in-ie11?forum=iewebdevelopment
Regards, Amir -
Convert XML values to internal table
Hi Experts
How can i convert XML values to internal table . i am getting all the values into the string.
this is my example
<?xml version="1.0" encoding="UTF-8"?><TEST><ZTEST><DEPTNO>HEADOFFICE</DEPTNO><DNAME>IT</DNAME><LOC>HYD</LOC><MANDT>003</MANDT></ZTEST></TEST>
i did create internal table with 4 fields.
Please help.XML DOM Processing in ABAP part I - Convert an ABAP table into XML file using SAP DOM Approach.
-
My XML value does not appear .
==================
Method
==================
public function ReadXML(myfile:String) {
xmlFile=myfile;
function onXMLLoad(event:Event):void {
var xml:XML=new XML(event.target.data);
//trace(xml);
trace("Number of Contacts : " + xml..person.length());
// This value appear
trace("First contact’s favorite food : " + xml.contacts.person[0].favoriteFood);
//This value does not appear
var loader:URLLoader=new URLLoader;
var url:URLRequest=new URLRequest(xmlFile);
loader.addEventListener(Event.COMPLETE,onXMLLoad);
loader.load(url);
=============
XML Structure
=============
<?xml version="1.0" encoding="iso-8859-1"?>
<xml>
<contacts>
<person name="Mike Chambers" favoriteFood="Bacon" />
<person name="John Doe" favoriteFood="Pez" />
</contacts>
</xml>attributes require an @ symbol first:
xml.contacts.person[0].@favoriteFood -
I am new to ActionScript 3 and have a project I would like to get some help on. I have an XML file on a server that has two types of parent nodes... an example is below:
<bodytypesuggestions>
<ID1>36</ID1>
<ID2>34</ID2>
<ID3>37</ID3>
</bodytype>
<bodytypes>
<ID1>34</ID1>
<ID2>32</ID2>
<ID3>35</ID3>
</bodytype>
The AS code below connects my flash to the URL:
import flash.net.*;
import flash.events.*;
var myXML:XMLList;
var url:URLRequest = new URLRequest("MYSERVER.COM");
var XMLLoader:URLLoader = new URLLoader(url);
XMLLoader.addEventListener(Event.COMPLETE, GetRecommendations);
XMLLoader.addEventListener(Event.CHANGE, updateAndGetRecommendations);
function GetSuggestions(event:Event):void {
if (XMLLoader.data) {
myXML = XMLList(XMLLoader.data);
var myDev:XMLList = new XMLList(XMLLoader.data)
var bodytypelist:XMLList = myDev..bodytypes
var bydytypesugglist:XMLList = myDev..bodytypesuggestions
trace(bodytypelist);
this["ID1"].text = bodytypelist.ID1;
this["ID1"].restrict = "0-9.";
this["ID1"].maxChars = 5;
this["ID2"].text = bodytypelist.ID2;
this["ID2"].restrict = "0-9.";
this["ID2"].maxChars = 5;
this["ID3"].text = bodytypelist.ID3;
this["ID3"].restrict = "0-9.";
this["ID3"].maxChars = 5;
Now in my flash file, I have 3 textInput fields that are populated with the above XML values from the bodytype child values.
My question is - how can I write a function that when a user changes a value in any one of the text fields, the data returned is from the bodytypesuggestions node value instantly, i.e. once a field value is changed, the other two will change accordingly. The actual XML on the server already handles those calculations. I hope this makes sense, I really need some help on this one.I am not 100% certain what you're asking for here...
I would tend to send XML rather than an XMLList string. I can't get the e4x filtering to work for an XMLList like that, which means (I assume) that you would need to iterate the list and using filtering on each XML object in the list. Perhaps I've missed something as you don't seem to be expressing a problem with loading the xml data and getting it into the textfields initially. I've not tried using the filtering on an XMLList directly before but could not get it working the way you have it. So in the following simulation I have wrapped the list in a top level tag to get it working the way I wanted.
Here is a non-loading simulation of what you seem to want. The difference here is that the GetSuggestions 'listener' is called manually with the data string rather than by the URLLoader's listener with the data attached to the URLLoader's dispatched event.
Hope that helps some.
var xStr:String="<bodytypesuggestions><ID1>36</ID1><ID2>34</ID2><ID3>37</ID3></bodytypesuggestions><bodytypes><ID1>34</ID1><ID2>32</ID2><ID3>35</ID3></bodytypes>";
var myXML:XML;
var suggestions:XMLList;
//requires 3 input textfields on the stage named ID1, ID2, ID3
function GetSuggestions(data:String):void {
if (data) {
var myXML:XML = XML("<wrapper>"+XMLList(data).toXMLString()+"</wrapper>");
var bodytypelist:XMLList = myXML..bodytypes;
suggestions = myXML..bodytypesuggestions;
ID1.text = bodytypelist.ID1;
ID1.restrict = "0-9.";
ID1.maxChars = 5;
ID2.text = bodytypelist.ID2;
ID2.restrict = "0-9.";
ID2.maxChars = 5;
ID3.text = bodytypelist.ID3;
ID3.restrict = "0-9.";
ID3.maxChars = 5;
GetSuggestions(xStr)
ID1.addEventListener(Event.CHANGE,myTextListener)
ID2.addEventListener(Event.CHANGE,myTextListener)
ID3.addEventListener(Event.CHANGE,myTextListener)
function myTextListener(e:Event):void{
var updates:Array = ['ID1','ID2','ID3'];
//check to see if current value is recognized
if (TextField(e.currentTarget).text == suggestions.elements(TextField(e.currentTarget).name).text()){
trace('found match')
for each(var fieldName:String in updates){
if (TextField(e.currentTarget).name==fieldName) continue;
TextField(this[fieldName]).text = suggestions.elements(fieldName).text();
trace(' set '+fieldName + ' to '+TextField(this[fieldName]).text) -
how can i capture a XML value (that i create myself) using java?? do anyone hav an example for that?? thanks
http://java.sun.com/xml
-
Failing to extract xml value using Jdom & Xpath
I have a method (getSingleNodeValue()) which when passed an xpatch expression will extract the value of the specified element in the xml document refered to in 'doc'. Assume doc at this point has been initialised as shown below and xmlInput is the buffer containing the xml content.
SAXBuilder builder = null;
Document doc = null;
XPath xpathInstance = null;
doc = builder.build(new StringReader(xmlInput));When i call the method, i pass the following xpath xpression
/TOP4A/PERLODSUMDEC/TINPLD1/text()Here is the method. It basically just takes an xml buffer and uses xpath to extract the value:
public static String getSingleNodeValue(String xpathExpr) throws Exception{
Text list = null;
try {
xpathInstance = XPath.newInstance(xpathExpr);
list = (Text) xpathInstance.selectSingleNode(doc);
} catch (JDOMException e) {
throw new Exception(e);
}catch (Exception e){
throw new Exception(e);
return list==null ? "?" : list.getText();
}The above method always returns "?" i.e. nothing is found so 'list' is null.
The xml document it looks at is
<TOP4A xmlns="http://www.testurl.co.uk/enment/gqr/3232/1">
<HEAD>
<Doc>ABCDUK1234</Doc>
</HEAD>
<PERLODSUMDEC>
<TINPLD1>10109000000000000</TINPLD1>
</PERLODSUMDEC>
</TOP4A>The same method works with other xml documents so i am not sure what is special about this one. There is no exception so the xml is valid xml. Its just that the method always sets 'list' to null. Any ideas?
Edit
Here is a running program testing the above:
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.xpath.*;
import java.io.IOException;
import java.io.StringReader;
public class XpathTest {
public static String getSingleNodeValue(String xpathExpr, String xmlInput) throws Exception{
Text list = null;
SAXBuilder builder = null;
Document doc = null;
XPath xpathInstance = null;
try {
builder = new SAXBuilder();
doc = builder.build(new StringReader(xmlInput));
xpathInstance = XPath.newInstance(xpathExpr);
list = (Text) xpathInstance.selectSingleNode(doc);
} catch (JDOMException e) {
throw new Exception(e);
}catch (Exception e){
throw new Exception(e);
return list==null ? "Nothing Found" : list.getText();
public static void main(String[] args){
String xmlInput1 = "<TOP4A xmlns=\"http://www.testurl.co.uk/enment/gqr/3232/1\"><HEAD><Doc>ABCDUK1234</Doc></HEAD><PERLODSUMDEC><TINPLD1>10109000000000000</TINPLD1></PERLODSUMDEC></TOP4A>";
String xpathExpr = "/TOP4A/PERLODSUMDEC/TINPLD1/text()";
XpathTest xp = new XpathTest();
try {
System.out.println(xp.getSingleNodeValue(xpathExpr, xmlInput1));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}When i run the above, the output is
Nothing foundEdit
I have run some further testing and it appears that if i remove the namespace url it does work. Not sure why yet. Is there any way i can tell it to ignore the namespace?
Edited by: ziggy on Sep 3, 2011 4:57 PMziggy wrote:
<TOP4A xmlns="http://www.testurl.co.uk/enment/gqr/3232/1">
<HEAD>
<Doc>ABCDUK1234</Doc>
</HEAD>
<PERLODSUMDEC>
<TINPLD1>10109000000000000</TINPLD1>
</PERLODSUMDEC>
</TOP4A>
It works fine, the problem is not with namespace, it is with url have given.
Editing:
Found a way to say the program to ignore namespace.
You have to use Xpath.addNamespace(prefix,uri), and pass the prefix to your pattern string.
If not clear refer the below code:
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.xpath.*;
import java.io.IOException;
import java.io.StringReader;
public class XpathTest {
public static String getSingleNodeValue(String xpathExpr, String xmlInput) throws Exception{
Text list = null;
SAXBuilder builder = null;
Document doc = null;
XPath xpathInstance = null;
try {
builder = new SAXBuilder();
doc = builder.build(new StringReader(xmlInput));
xpathInstance = XPath.newInstance(xpathExpr);
xpathInstance.addNamespace("ns","http://www.testurl.co.uk/enment/gqr/3232/1");
list = (Text) xpathInstance.selectSingleNode(doc);
} catch (JDOMException e) {
throw new Exception(e);
}catch (Exception e){
throw new Exception(e);
return list==null ? "Nothing Found" : list.getText();
public static void main(String[] args){
String xmlInput1 = "<TOP4A xmlns=\"http://www.testurl.co.uk/enment/gqr/3232/1\"><HEAD><Doc>ABCDUK1234</Doc></HEAD><PERLODSUMDEC><TINPLD1>10109000000000000</TINPLD1></PERLODSUMDEC></TOP4A>";
String xpathExpr = "/ns:TOP4A/ns:PERLODSUMDEC/ns:TINPLD1/text()";
XpathTest xp = new XpathTest();
try {
System.out.println(xp.getSingleNodeValue(xpathExpr, xmlInput1));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}Edited by: 833545 on Sep 8, 2011 11:35 PM -
How to extract data from CLOB Datatype having XML values
Hi,
I am facing problem in extracting data from a TAble FCT_A where OBJECT_CONTENT field(Datatype CLOB) is having data of XML type.
Below are the value:
<ras-cube>
<jndiDataSourceName>datasource_etl</jndiDataSourceName>
<dimensions class="vector">
<string>CUG_IND</string>
<string>EVENT_DATE</string>
<string>EVENT_DIRECTION_KEY</string>
<string>EVENT_TIME_SLOT_KEY</string>
<string>EVENT_TYPE_KEY</string>
<string>FAF_IND</string>
<string>FILTERED_OUT_FLAG</string>
<string>IN_TG_ID_KEY</string>
<string>LONG_EVENT_IND</string>
<string>NE_ID_KEY</string>
<string>NODE_ADDRESS</string>
<string>OTHER_MSISDN_DIAL_DIGIT_KEY</string>
<string>OUT_TG_ID_KEY</string>
<string>RATING_DELAY_IND</string>
<string>RI_MISMATCH_IND</string>
<string>SERVED_MSISDN_DIAL_DIGIT_KEY</string>
<string>SERVED_MSRN_DIAL_DIGIT_KEY</string>
<string>SRV_TYPE_KEY</string>
<string>SUBS_BU_KEY</string>
<string>SYS_ID_KEY</string>
<string>TERMINATION_REASON_KEY</string>
<string>THIRD_PARTY_DIAL_DIGIT_KEY</string>
<string>ZERO_FLAG_KEY</string>
</dimensions>
<measures class="vector">
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>CHARGE</targetName>
<expression>SUM(FCT_RATED.CHARGE)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>COMPUTED_VOLUME</targetName>
<expression>SUM(FCT_RATED.COMPUTED_VOLUME)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>DOWNLINK_VOLUME</targetName>
<expression>SUM(FCT_RATED.DOWNLINK_VOLUME)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>ORIGINAL_DUR</targetName>
<expression>SUM(FCT_RATED.ORIGINAL_DUR)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>RA_CHARGE</targetName>
<expression>SUM(FCT_RATED.RA_CHARGE)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>RECORD_COUNT</targetName>
<expression>COUNT(FCT_RATED.*)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>UPLINK_VOLUME</targetName>
<expression>SUM(FCT_RATED.UPLINK_VOLUME)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
</measures>
<dimensionMap class="linked-hash-map">
<entry>
<string>FCT_RATED</string>
<null/>
</entry>
</dimensionMap>
<cubeStorageConfig>
<partitionColumn>EVENT_DATE</partitionColumn>
<tableSpaceName>ORV5_ETL_DFLT</tableSpaceName>
<isLogging>false</isLogging>
<isCompressed>false</isCompressed>
<noOfHashPartition>10</noOfHashPartition>
<partitionScheme>1</partitionScheme>
</cubeStorageConfig>
<cubeType>1</cubeType>
<name>MX_RATED</name>
<label></label>
<parentNames>
<string>FCT_RATED</string>
</parentNames>
<otherProperties class="linked-hash-map"/>
</ras-cube>
I want to extract expression tag in the above XML types
Kindly any help will be needful for me
Thanks and Regards9i
with FCT_A as (
select xmltype('
<ras-cube>
<jndiDataSourceName>datasource_etl</jndiDataSourceName>
<dimensions class="vector">
<string>CUG_IND</string>
<string>EVENT_DATE</string>
<string>EVENT_DIRECTION_KEY</string>
<string>EVENT_TIME_SLOT_KEY</string>
<string>EVENT_TYPE_KEY</string>
<string>FAF_IND</string>
<string>FILTERED_OUT_FLAG</string>
<string>IN_TG_ID_KEY</string>
<string>LONG_EVENT_IND</string>
<string>NE_ID_KEY</string>
<string>NODE_ADDRESS</string>
<string>OTHER_MSISDN_DIAL_DIGIT_KEY</string>
<string>OUT_TG_ID_KEY</string>
<string>RATING_DELAY_IND</string>
<string>RI_MISMATCH_IND</string>
<string>SERVED_MSISDN_DIAL_DIGIT_KEY</string>
<string>SERVED_MSRN_DIAL_DIGIT_KEY</string>
<string>SRV_TYPE_KEY</string>
<string>SUBS_BU_KEY</string>
<string>SYS_ID_KEY</string>
<string>TERMINATION_REASON_KEY</string>
<string>THIRD_PARTY_DIAL_DIGIT_KEY</string>
<string>ZERO_FLAG_KEY</string>
</dimensions>
<measures class="vector">
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>CHARGE</targetName>
<expression>SUM(FCT_RATED.CHARGE)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>COMPUTED_VOLUME</targetName>
<expression>SUM(FCT_RATED.COMPUTED_VOLUME)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>DOWNLINK_VOLUME</targetName>
<expression>SUM(FCT_RATED.DOWNLINK_VOLUME)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>ORIGINAL_DUR</targetName>
<expression>SUM(FCT_RATED.ORIGINAL_DUR)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>RA_CHARGE</targetName>
<expression>SUM(FCT_RATED.RA_CHARGE)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>RECORD_COUNT</targetName>
<expression>COUNT(FCT_RATED.*)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<com.connectiva.onereview.rasobjects.cube.CubeMeasure>
<targetName>UPLINK_VOLUME</targetName>
<expression>SUM(FCT_RATED.UPLINK_VOLUME)</expression>
<persist>true</persist>
</com.connectiva.onereview.rasobjects.cube.CubeMeasure>
</measures>
<dimensionMap class="linked-hash-map">
<entry>
<string>FCT_RATED</string>
<null/>
</entry>
</dimensionMap>
<cubeStorageConfig>
<partitionColumn>EVENT_DATE</partitionColumn>
<tableSpaceName>ORV5_ETL_DFLT</tableSpaceName>
<isLogging>false</isLogging>
<isCompressed>false</isCompressed>
<noOfHashPartition>10</noOfHashPartition>
<partitionScheme>1</partitionScheme>
</cubeStorageConfig>
<cubeType>1</cubeType>
<name>MX_RATED</name>
<label></label>
<parentNames>
<string>FCT_RATED</string>
</parentNames>
<otherProperties class="linked-hash-map"/>
</ras-cube>') OBJECT_CONTENT from dual
SELECT EXTRACTVALUE(value(d), '//expression/text()', '') exp
FROM fct_a t,
TABLE(XMLSEQUENCE(EXTRACT (
t.object_content,
'//ras-cube/measures/com.connectiva.onereview.rasobjects.cube.CubeMeasure/expression'
))) dEdited by: Beijing on Aug 10, 2009 9:21 AM -
Best way to extract XML value wiith an xpath
Hello,
I wonder what is the best way to extract text value from XmlType with an xpath.
I need to insert a row inside a table where the row's data come from xpath extractions of an XmlType. I do a lot of (approximative 20) :
EXTRACTVALUE(var.myxmltype , '/an/xpath/to/extract/elem1').
EXTRACTVALUE(var.myxmltype , '/an/xpath/to/extract/elemI').
EXTRACTVALUE(var.myxmltype , '/an/xpath/to/extract/elem20').
inside the insert statement
Is this way is the best or is there a more optimal way ?
For example extracting the node '/an/xpath/to/extract/' and sarting from this node extracting "elem1", ... , "elemI", "elemN" children.
Thanks for your help,
Regards,
NicolasHi Nicolas,
The answer depends on your actual storage method (binary, OR, CLOB?), and db version.
You can try XMLTable, it might be better in this case :
SELECT x.elem1, x.elem2, ... , x.elem20
FROM your_table t
, XMLTable(
'/an/xpath/to/extract'
passing t.myxmltype
columns elem1 varchar2(30) path 'elem1'
, elem2 varchar2(30) path 'elem2'
, elem20 varchar2(30) path 'elem20'
) x
; -
Extracting XML values with namespace prefixes
Hint: I put this topic in "SQL and PL/SQL" but that was a bad idea, I think.
Hi!
I have a XML file:<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/styl.xsl"?>
<wnio:Deklaracja
xmlns:adr="http://crd.gov.pl/xml/schematy/adres/2008/05/09/"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:inst="http://crd.gov.pl/xml/schematy/instytucja/2008/05/09/"
xmlns:meta="http://crd.gov.pl/xml/schematy/meta/2008/05/09/"
xmlns:oso="http://crd.gov.pl/xml/schematy/osoba/2008/05/09/"
xmlns:str="http://crd.gov.pl/xml/schematy/struktura/2009/11/16/"
xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xsi:schemaLocation="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/ http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/schemat.xsd">
<wnio:OpisDokumentu><str:CID>[email protected]</str:CID><meta:Identyfikator typIdentyfikatora="idFormularza"><meta:Wartosc>InstytucjaPubliczna/Deklaracja podatku od środków transportowych DT-1</meta:Wartosc></meta:Identyfikator></wnio:OpisDokumentu>
<wnio:Naglowek>
<wnio:KodFormularza kodSystemowy="DT-1(3)"/>
<wnio:WariantFormularza>3</wnio:WariantFormularza>
<wnio:Rok>2008</wnio:Rok>
<wnio:ObowiazekSkladaniaDeklaracji>1</wnio:ObowiazekSkladaniaDeklaracji>
<wnio:MiejsceSkladania/>
</wnio:Naglowek>
<wnio:Podatnik>
<wnio:OsobaPrawna>
<wnio:NIP>345678901</wnio:NIP>
<wnio:PelnaNazwa>Testowa Instytucja Publiczna</wnio:PelnaNazwa>
<wnio:NazwaSkrocona/>
<wnio:REGON>234512345</wnio:REGON>
</wnio:OsobaPrawna>
<wnio:AdresSiedzibyZamieszkania>
<wnio:KodKraju>PL</wnio:KodKraju>
<wnio:Wojewodztwo>ŚLĄSKIE</wnio:Wojewodztwo>
<wnio:Powiat>Katowice</wnio:Powiat>
<wnio:Gmina>Katowice (gmina miejska)</wnio:Gmina>
<wnio:Ulica>ul. Mikołowska</wnio:Ulica>
<wnio:NrDomu>100</wnio:NrDomu>
<wnio:NrLokalu>924</wnio:NrLokalu>
<wnio:Miejscowosc>Katowice (miasto)</wnio:Miejscowosc>
<wnio:KodPocztowy>40-065</wnio:KodPocztowy>
<wnio:Poczta>Katowice</wnio:Poczta>
</wnio:AdresSiedzibyZamieszkania>
</wnio:Podatnik>
<wnio:PozycjeSzczegolowe>
<wnio:D.1>
<wnio:P_22/>
<wnio:P_23/>
</wnio:D.1>
<wnio:D.2>
<wnio:P_28/>
<wnio:P_29/>
</wnio:D.2>
<wnio:P_82/>
<wnio:P_83/>
</wnio:PozycjeSzczegolowe>
<wnio:Zalacznik_DT-1A>
<wnio:P_1/>
<wnio:P_2/>
<wnio:P_22>1</wnio:P_22>
</wnio:Zalacznik_DT-1A>
<wnio:Zalacznik_DT-1A>
<wnio:P_1/>
<wnio:P_2/>
<wnio:P_22>3</wnio:P_22>
</wnio:Zalacznik_DT-1A>
</wnio:Deklaracja>and an overloaded function:
function dodaj_DT1_z_xml(p_dt1 in out nocopy XMLType) return number as
r_dt1 POD_SRTR_DT1%rowtype;
r_dt1a POD_SRTR_DT1A%rowtype;
r_sdek POD_SRTR_DEKLARACJE%rowtype;
l_wariantDT1 number(2);
l_xosf XMLType;
l_xosp XMLType;
l_xadr XMLType;
l_xszcz XMLType;
l_zal XMLType;
l_z XMLType;
l_zno pls_integer;
l_xml XMLType;
l_ns varchar2(10);
-- xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"
begin
if --p_dt1.existsNode('/wnio:Deklaracja')=0 and
p_dt1.existsNode('/Deklaracja','xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"')=0
then return -2; end if;
if p_dt1.existsNode('/wnio:Deklaracja')=1 then
l_ns := 'wnio:';
end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja')=0 then return -2; end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'Naglowek')=0 then return -3; end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'Podatnik')=0 then return -4; end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'PozycjeSzczegolowe')=0 then return -5; end if;
return 1;
end;
function dodaj_DT1_z_xml(p_dt1 in out nocopy CLOB) return number is
l_xml XMLType;
begin
l_xml := XMLType(p_dt1);
return dodaj_DT1_z_xml(l_xml);
end dodaj_DT1_z_xml;I run the code:declare
v_clob CLOB;
v_out number;
begin
SELECT dok_content INTO v_clob FROM EPUAP.epuap_dokumenty WHERE dok_id=13;
v_out := POD_PCK_SRTR_DT1.DODAJ_DT1_Z_XML(v_clob);
DBMS_OUTPUT.put_line(v_out);
end;the output is -2. What must I change to find the node "wnio:Deklaracja"? I'm newbie in XML and namespaces :(
Help me, please...
Oracle version is 10.2.0.3Hi,
If you declare a namespace prefix then corresponding elements must be qualified.
So, either do :
p_dt1.existsNode('/wnio:Deklaracja','xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"')or use a default namespace declaration :
p_dt1.existsNode('/Deklaracja','xmlns="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"')BTW, could you explain what are you trying to accomplish? -
Extracting XML values with namespace
Hi!
I have a XML file:<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/styl.xsl"?>
<wnio:Deklaracja
xmlns:adr="http://crd.gov.pl/xml/schematy/adres/2008/05/09/"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:inst="http://crd.gov.pl/xml/schematy/instytucja/2008/05/09/"
xmlns:meta="http://crd.gov.pl/xml/schematy/meta/2008/05/09/"
xmlns:oso="http://crd.gov.pl/xml/schematy/osoba/2008/05/09/"
xmlns:str="http://crd.gov.pl/xml/schematy/struktura/2009/11/16/"
xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xsi:schemaLocation="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/ http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/schemat.xsd">
<wnio:OpisDokumentu><str:CID>[email protected]</str:CID><meta:Identyfikator typIdentyfikatora="idFormularza"><meta:Wartosc>InstytucjaPubliczna/Deklaracja podatku od środków transportowych DT-1</meta:Wartosc></meta:Identyfikator></wnio:OpisDokumentu>
<wnio:Naglowek>
<wnio:KodFormularza kodSystemowy="DT-1(3)"/>
<wnio:WariantFormularza>3</wnio:WariantFormularza>
<wnio:Rok>2008</wnio:Rok>
<wnio:ObowiazekSkladaniaDeklaracji>1</wnio:ObowiazekSkladaniaDeklaracji>
<wnio:MiejsceSkladania/>
</wnio:Naglowek>
<wnio:Podatnik>
<wnio:OsobaPrawna>
<wnio:NIP>345678901</wnio:NIP>
<wnio:PelnaNazwa>Testowa Instytucja Publiczna</wnio:PelnaNazwa>
<wnio:NazwaSkrocona/>
<wnio:REGON>234512345</wnio:REGON>
</wnio:OsobaPrawna>
<wnio:AdresSiedzibyZamieszkania>
<wnio:KodKraju>PL</wnio:KodKraju>
<wnio:Wojewodztwo>ŚLĄSKIE</wnio:Wojewodztwo>
<wnio:Powiat>Katowice</wnio:Powiat>
<wnio:Gmina>Katowice (gmina miejska)</wnio:Gmina>
<wnio:Ulica>ul. Mikołowska</wnio:Ulica>
<wnio:NrDomu>100</wnio:NrDomu>
<wnio:NrLokalu>924</wnio:NrLokalu>
<wnio:Miejscowosc>Katowice (miasto)</wnio:Miejscowosc>
<wnio:KodPocztowy>40-065</wnio:KodPocztowy>
<wnio:Poczta>Katowice</wnio:Poczta>
</wnio:AdresSiedzibyZamieszkania>
</wnio:Podatnik>
<wnio:PozycjeSzczegolowe>
<wnio:D.1>
<wnio:P_22/>
<wnio:P_23/>
</wnio:D.1>
<wnio:D.2>
<wnio:P_28/>
<wnio:P_29/>
</wnio:D.2>
<wnio:P_82/>
<wnio:P_83/>
</wnio:PozycjeSzczegolowe>
<wnio:Zalacznik_DT-1A>
<wnio:P_1/>
<wnio:P_2/>
<wnio:P_22>1</wnio:P_22>
</wnio:Zalacznik_DT-1A>
<wnio:Zalacznik_DT-1A>
<wnio:P_1/>
<wnio:P_2/>
<wnio:P_22>3</wnio:P_22>
</wnio:Zalacznik_DT-1A>
</wnio:Deklaracja>and an overloaded function:
function dodaj_DT1_z_xml(p_dt1 in out nocopy XMLType) return number as
r_dt1 POD_SRTR_DT1%rowtype;
r_dt1a POD_SRTR_DT1A%rowtype;
r_sdek POD_SRTR_DEKLARACJE%rowtype;
l_wariantDT1 number(2);
l_xosf XMLType;
l_xosp XMLType;
l_xadr XMLType;
l_xszcz XMLType;
l_zal XMLType;
l_z XMLType;
l_zno pls_integer;
l_xml XMLType;
l_ns varchar2(10);
-- xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"
begin
if --p_dt1.existsNode('/wnio:Deklaracja')=0 and
p_dt1.existsNode('/Deklaracja','xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"')=0
then return -2; end if;
if p_dt1.existsNode('/wnio:Deklaracja')=1 then
l_ns := 'wnio:';
end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja')=0 then return -2; end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'Naglowek')=0 then return -3; end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'Podatnik')=0 then return -4; end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'PozycjeSzczegolowe')=0 then return -5; end if;
return 1;
end;
function dodaj_DT1_z_xml(p_dt1 in out nocopy CLOB) return number is
l_xml XMLType;
begin
l_xml := XMLType(p_dt1);
return dodaj_DT1_z_xml(l_xml);
end dodaj_DT1_z_xml;I run the code:declare
v_clob CLOB;
v_out number;
begin
SELECT dok_content INTO v_clob FROM EPUAP.epuap_dokumenty WHERE dok_id=13;
v_out := POD_PCK_SRTR_DT1.DODAJ_DT1_Z_XML(v_clob);
DBMS_OUTPUT.put_line(v_out);
end;the output is -2. What must I change to find the node "wnio:Deklaracja"? I'm newbie in XML and namespaces :(
Help me, please...Thanks, BluShadow!
added:
What if the structure of the XML is not always the same? Suppose that <aa:USER_INFO> sometimes contains subnode <aa:AUX>.
WITH t as (select XMLTYPE('
<RECSET xmlns:aa="http://www.w3.org">
<aa:REC>
<aa:COUNTRY>1</aa:COUNTRY>
<aa:POINT>1800</aa:POINT>
<aa:USER_INFO>
<aa:USER_ID>1</aa:USER_ID>
<aa:TARGET>28</aa:TARGET>
<aa:STATE>6</aa:STATE>
<aa:TASK>12</aa:TASK>
<aa:AUX>
<aa:AUX1>111</aa:AUX1> <aa:AUX2>222</aa:AUX2>
</aa:AUX>
</aa:USER_INFO>
<aa:USER_INFO>
<aa:USER_ID>5</aa:USER_ID>
<aa:TARGET>19</aa:TARGET>
<aa:STATE>1</aa:STATE>
<aa:TASK>90</aa:TASK>
</aa:USER_INFO>
</aa:REC>
<aa:REC>
<aa:COUNTRY>2</aa:COUNTRY>
<aa:POINT>2400</aa:POINT>
<aa:USER_INFO>
<aa:USER_ID>3</aa:USER_ID>
<aa:TARGET>14</aa:TARGET>
<aa:STATE>7</aa:STATE>
<aa:TASK>5</aa:TASK>
<aa:AUX>
<aa:AUX1>333</aa:AUX1>
</aa:AUX>
</aa:USER_INFO>
</aa:REC>
</RECSET>') as xml from dual)
-- END OF TEST DATA
select x.country, x.point, y.user_id, y.target, y.state, y.task, z.aux1, z.aux2
from t
,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
'/RECSET/aa:REC'
PASSING t.xml
COLUMNS country NUMBER PATH '/aa:REC/aa:COUNTRY'
,point NUMBER PATH '/aa:REC/aa:POINT'
,user_info XMLTYPE PATH '/aa:REC/*'
) x
,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
'/aa:USER_INFO'
PASSING x.user_info
COLUMNS user_id NUMBER PATH '/aa:USER_INFO/aa:USER_ID'
,target NUMBER PATH '/aa:USER_INFO/aa:TARGET'
,state NUMBER PATH '/aa:USER_INFO/aa:STATE'
,task NUMBER PATH '/aa:USER_INFO/aa:TASK'
,aux XMLTYPE PATH '/aa:USER_INFO/*'
) y
,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
'/aa:AUX'
PASSING y.aux
COLUMNS aux1 NUMBER PATH '/aa:AUX/aa:AUX1'
,aux2 NUMBER PATH '/aa:AUX/aa:AUX2'
) z;This query returns only 2 rows. I'd like to have 3 rows returned :) 3 rows are returned when I add an empty <aa:AUX> node to the data but I wants to have 3 rows when the <aa:AUX> is missed also. -
XML data extraction in 8.1.7
Hi,
I am new to xmlparser. I have the following xml file as CLOB in oracle 8.1.7 dB. I need to extract the data, based on the user request. If the user requests "Collateral Assets", then i have to extract the data group, related to that "Collateral Assets".
If the user requests "Liabilities", then i have to extract the data group, related to that "Liabilities".
Can anybody help, with sample source code. I need to use XMLDOM api's.
Thanks
<cashflowSummaryReport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Projects\Reports\cashflowSummaryReport.xsd">
<name1>Cashflow CDO Summary Report</name1>
<description1>Sample Cashflow for documentation</description1>
<analysisDate1>2001-01-01</analysisDate1>
<links>
<link>
<name>Reports Main</name>
<location>summary.html</location>
</link>
<link>
<name>RiskMetrics Group</name>
<location>http://www.riskmetrics.com</location>
</link>
</links>
<dataGroup>
<name>Collateral Assets</name>
<description>Summary of collateral assets</description>
<links>
<link>
<name>View Collateral Assets separately</name>
<location>cashflowSummaryReport_collateral.html</location>
</link>
</links>
<header>
<keyHeader>
<title>Detail</title>
</keyHeader>
<columnHeader>
<title>Value</title>
</columnHeader>
</header>
<data>
<key>
<value>Total Par Value</value>
</key>
<column>
<value>150000000</value>
</column>
</data>
<data>
<key>
<value>Number of Obligors</value>
</key>
<column>
<value>98</value>
</column>
</data>
</dataGroup>
<dataGroup>
<name>Liabilities</name>
<description>Summary of liabilities by tranche/notes</description>
<system>S+P</system>
<links>
<link>
<name>View Liabilities separately</name>
<location>cashflowSummaryReport_liabilities.html</location>
</link>
</links>
<header>
<keyHeader>
<title>Tranche / Notes</title>
</keyHeader>
<columnHeader>
<title>Notional</title>
</columnHeader>
<columnHeader>
<title>Market Price</title>
</columnHeader>
<columnHeader>
<title>Coupon</title>
</columnHeader>
<columnHeader>
<title>OC Trigger</title>
</columnHeader>
<columnHeader>
<title>Current OC</title>
</columnHeader>
<columnHeader>
<title>IC Trigger</title>
</columnHeader>
<columnHeader>
<title>Current IC</title>
</columnHeader>
</header>
<data>
<key>
<value>Senior notes - floating</value>
<link>CashFlowReport_Senior notes - floating.html</link>
</key>
<column>
<value>90000000</value>
</column>
<column>
<value>90000000</value>
</column>
<column>
<value>LIBOR+0.50%</value>
</column>
<column>
<value>-</value>
</column>
<column>
<value>-</value>
</column>
<column>
<value>-</value>
</column>
<column>
<value>-</value>
</column>
</data>
</dataGroup>
</cashflowSummaryReport>There is no native XML data types in 8i.
-
I have an XML document with the following structure:
<foo>
<foo id="F1">television</foo>
<foo id="F2">car</foo>
</foo>
foo id can be none or up to 99. So I want to extract the tag "F1", "F2", etc. and its content when it shows up in a document to enter them in separate fields in a database. I have tried different codes but with no luck. These two are my latest methods but they don't work as expected. The second method gives an error message at the line "matcher = pattern.matcher(xml)". If any one could help I would appreciate it very much.
_xmlFile is my parsed document. I know it works because I have other methods using getTextContent() with specific tags and work well.
private void processFoo(Document _xmlFile){
String xPath = null;
String value = null;
xPath = "/*/foo";
try{
NodeList nodelist = XPathAPI.selectNodeList(_xmlFile, xPath);
for(int i2 = 0; i2 < nodelist.getLength(); i2++){
Element elem =(Element)nodelist.item(i2);
value = elem.toString();
value = value.replaceAll("\t", "");
value = value.replaceAll("\n", "");
value = value.replaceAll("\r", "");
}catch(TransformerException transformerexception){
addFoo(value);
public void addFoo(String _xml)
String regex = null;
String id = null;
String content = null;
Pattern pattern = null;
Matcher matcher = null;
String sql = null;
int index = 0;
String xml = _xml;
regex = "\\<foo id=\"F(.+?)\">";
pattern = Pattern.compile(regex);
matcher = pattern.matcher(xml);
while (matcher.find())
id = matcher.group(1);
id = id.replaceAll("'", "");
index = matcher.end(1)+2;
index = xml.indexOf("</foo>", index);
content = xml.substring(matcher.end(1)+2, index);
content = processOfString(content);
sql = "INSERT INTO my.Foo (Foo_Id, Foo_Content) VALUES " + "(" + id + ", '" + content + "')";
//System.out.println(sql);
insertQuery(sql, false);
xml = xml.substring(index+11, xml.length());
matcher = pattern.matcher(xml);
}Although I still have a question (which is at the bottom) I finally got what I wanted with the following method.
private void addFoo(Document _xmlFile){
String foocontent = null;
String fooref = null;
Document doc = _xmlFile;
String foopath = "foo";
String sql = null;
NodeList foo = doc.getElementsByTagName(foopath);
for (int i = 0; i < foo.getLength(); i++){
Element foos = (Element) foo.item(i);
fooref = foos.getAttribute("id");
foocontent = foos.getTextContent();
foocontent = foocontent.replaceAll("\t", "");
footcontent = footcontent.replaceAll("\n", "");
foocontent = foocontent.replaceAll("\r", "");
//System.out.println(fooref);
//System.out.print(foocontent);
sql = "INSERT INTO insider.footnote SET fooRef = ?, fooText = ?";
try{
PreparedStatement addfoo = con.prepareStatement(sql);
addfoo.setString(1, fooref);
addfoo.setString(2, foocontent);
addfoo.executeUpdate();
}catch(SQLException ex){
System.err.println("SQLException: " + ex.getMessage());
my foo table has a primary key that I need as a foreign key in ABC table. So I was wondering if there is anything in java that would allow me to send the key to ABC every time the foo table is updated. Actually, it would better if I can store the key in a variable that I send later with other data that needs to be input into the ABC table.
Thanks.
Maybe you are looking for
-
Setting PAL/NTSC format with OneStep in iDVD 5
I'm trying to create a DVD from some MiniDV tapes I've recorded, but I need to make sure it's recorded in PAL format as it's being sent overseas. I'm using the OneStep option in iDVD, but the only place I could find to set PAL/NTSC is in the preferen
-
JTable not working in JDK 1.6
Hi In my Application I am using JTable for diplay and sorting purpose.Its properly working with JRE 1.5. But When i try to run the same application in JRE 1.6 the sorting functionality is not working properly. plz let me know what is the difference b
-
Delievry for "0" qty should not be allowed
Dear All, Currently i am able to create delivery, PGI & Invoice for the "0" qty. This happens normally when material is NOT available for delivery, users put "0" qty and do delivery & PGI. I want to restrict the same. System should give error wheneve
-
Toolbar visibility button (lozenge)?
greetings, just transitioning from 10.6 to 10.7. many subtle surprises, not all of them good... this is driving me nuts. where has the "show/hide" toolbar button or lozenge gone in the title bar in 10.7? on MBPro, screen real estate is still a val
-
Unable to print the adobe form Genrated by webdynpro
Hi Experts, I have generated a adobe form using webdynpro Java. It sucessfully loading the adobe form in the browser but when I click print button above the form. It just opens acorbat reader console and doesnt print the form. Is there any additional