How Can One use XML data into our Java Program
I have an Java Program and an XML file contaning data. I want to parse the xml data and use into my Java Program. How can I do so.
Check out the org.xml.sax.XMLReader class.
Similar Messages
-
How to read an XML file into a java program?
hi,
i want to load the following very simple xml file in my java program.
<root>
<weblogic>
<url value="t3://192.168.1.160:7001" />
<context value="weblogic.jndi.WLInitialContextFactory" />
</weblogic>
</root>
I am getting the error: " Line=1: cvc-elt.1: Cannot find the declaration of element 'root'."
What might be the problem can anyone help me out.
My java class code is:
public class BIXMLReader {
/** All output will use this encoding */
static final String outputEncoding = "UTF-8";
// Parses an XML file and returns a DOM document.
// If validating is true, the contents is validated against the DTD
// specified in the file.
public static Document parseXmlFile(String filename, boolean validating) {
try {
// Create a builder factory
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setIgnoringComments(false);
factory.setIgnoringElementContentWhitespace(false);
factory.setCoalescing(false);
factory.setValidating(validating);
// Create the builder and parse the file
System.out.println("filename = " + filename);
DocumentBuilder db = factory.newDocumentBuilder();
// Set an ErrorHandler before parsing
OutputStreamWriter errorWriter = new OutputStreamWriter(System.err, outputEncoding);
db.setErrorHandler(new MyErrorHandler(new PrintWriter(errorWriter, true)));
Document doc = db.parse(new File(filename));
System.out.println(doc.toString());
return doc;
} catch (SAXException e) {
System.out.println("A parsing error occurred; the xml input is not valid. " + e.getMessage());
} catch (ParserConfigurationException e) {
System.out.println("Parser configuration exception has occured");
} catch (IOException e) {
System.out.println("IO Exception has occured " + e.getMessage());
return null;
// Error handler to report errors and warnings
private static class MyErrorHandler implements ErrorHandler {
/** Error handler output goes here */
private PrintWriter out;
MyErrorHandler(PrintWriter out) {
this.out = out;
* Returns a string describing parse exception details
private String getParseExceptionInfo(SAXParseException spe) {
String systemId = spe.getSystemId();
if (systemId == null) {
systemId = "null";
String info = "URI=" + systemId +
" Line=" + spe.getLineNumber() +
": " + spe.getMessage();
return info;
// The following methods are standard SAX ErrorHandler methods.
// See SAX documentation for more info.
public void warning(SAXParseException spe) throws SAXException {
out.println("Warning: " + getParseExceptionInfo(spe));
public void error(SAXParseException spe) throws SAXException {
String message = "Error: " + getParseExceptionInfo(spe);
throw new SAXException(message);
public void fatalError(SAXParseException spe) throws SAXException {
String message = "Fatal Error: " + getParseExceptionInfo(spe);
throw new SAXException(message);
}ok thanks, i can get the elements, but why did it not validate it?
I want to read the child nodes of "weblogic" not by their name but by their index. Because i dont want to confine the reader so i want to read all the child nodes of weblogic (looping over them). i m doing the following but its not returning me the correct result and giving me the wrong count of child nodes.
Element elementNode = (Element)doc.getElementsByTagName("weblogic").item(0);
NodeList nodeList = elementNode.getChildNodes();
int length = nodeList.getLength();
System.out.println("length = "+ length); // the length its giving is 5 but i shuld get only 2
for(int i=0; i < length; i++) {
Element elmChild = (Element) nodeList.item(i);
System.out.println(elmChild.getAttribute("value"));
what might be the problem? -
HT1338 How can i use my data on windows or mac when i use one of them in the same time?
Hi,
i have a Mac book with 2 operating system, ( Windows& mac). How can i use my data on windows or mac when i use one of them in the same time?
Thank youThe following article(s) may help you.
Resolving duplicate calendars
Resolving duplicate contacts -
How can I use home sharing between our iphones, so that we can create playlists with songs from both of our libraries? We share a Macbook Pro (separate accounts) and each have the new iphone, but when I have my iphone and try to create a new playlist, I can only grab songs from one account. Is there a way to create a playlist using both accounts since we are sharing?
Does it have to be created within iTunes first on our Mac?The short answer: because Home Sharing isn't designed for sharing apps, and apps aren't designed to be shared.
The longer answer: Think of it like this...
You download some music in iTunes. With Home Sharing, another user can listen to it by streaming it over the network. But the data itself is on your computer. If you turn off the computer or take it off the network, the other user can't access it.
But if you send another user the app, they aren't just streaming the data- they installed it on their iOS device. Because they weren't the one that purchased it, such a transfer could easily be considered "piracy" or "stealing," and nobody likes that (least of all, Apple).
When iTunes sees this app, it obviously recognized it, as if saying, "Hey, how did you get this app on your device, if I have no record of you purchasing/downloading it from the iTunes store?"
post edited to correct spelling errors -
How can I use XStream to persist complicated Java Object to XML & backward
Dear Sir:
I met a problem as demo in my code below when i use XTream to persist my Java Object;
How can I use XStream to persist complicated Java Object to XML & backward??
See
[1] main code
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
public class PhoneList {
ArrayList<PhoneNumber> phones;
ArrayList<Person> person;
private PhoneList myphonelist ;
private LocationTest location;
private PhoneList(String name) {
phones = new ArrayList<PhoneNumber>();
person = new ArrayList<Person>();
public ArrayList<PhoneNumber> getphones() {
return phones;
public ArrayList<Person> getperson() {
return person;
public void addPhoneNumber(PhoneNumber b1) {
this.phones.add(b1);
public void removePhoneNumber(PhoneNumber b1) {
this.phones.remove(b1);
public void addPerson(Person p1) {
this.person.add(p1);
public void removePerson(Person p1) {
this.person.remove(p1);
public void BuildList(){
location = new LocationTest();
XStream xstream = new XStream();
myphonelist = new PhoneList("PhoneList");
Person joe = new Person("Joe, Wallace");
joe.setPhone(new PhoneNumber(123, "1234-456"));
joe.setFax(new PhoneNumber(123, "9999-999"));
Person geo= new Person("George Nixson");
geo.setPhone(new PhoneNumber(925, "228-9999"));
geo.getPhone().setLocationTest(location);
myphonelist.addPerson(joe);
myphonelist.addPerson(geo);
public PhoneList(){
XStream xstream = new XStream();
BuildList();
saveStringToFile("C:\\temp\\test\\PhoneList.xml",convertToXML(myphonelist));
public void saveStringToFile(String fileName, String saveString) {
BufferedWriter bw = null;
try {
bw = new BufferedWriter(
new FileWriter(fileName));
try {
bw.write(saveString);
finally {
bw.close();
catch (IOException ex) {
ex.printStackTrace();
//return saved;
public String getStringFromFile(String fileName) {
BufferedReader br = null;
StringBuilder sb = new StringBuilder();
try {
br = new BufferedReader(
new FileReader(fileName));
try {
String s;
while ((s = br.readLine()) != null) {
// add linefeed (\n) back since stripped by readline()
sb.append(s + "\n");
finally {
br.close();
catch (Exception ex) {
ex.printStackTrace();
return sb.toString();
public String convertToXML(PhoneList phonelist) {
XStream xstream = new XStream(new DomDriver());
xstream.setMode(xstream.ID_REFERENCES) ;
return xstream.toXML(phonelist);
public static void main(String[] args) {
new PhoneList();
}[2].
import java.io.Serializable;
import javax.swing.JFrame;
public class PhoneNumber implements Serializable{
private String phone;
private String fax;
private int code;
private String number;
private String address;
private String school;
private LocationTest location;
public PhoneNumber(int i, String str) {
setCode(i);
setNumber(str);
address = "4256, Washington DC, USA";
school = "Washington State University";
public Object getPerson() {
return null;
public void setPhone(String phone) {
this.phone = phone;
public String getPhone() {
return phone;
public void setFax(String fax) {
this.fax = fax;
public String getFax() {
return fax;
public void setCode(int code) {
this.code = code;
public int getCode() {
return code;
public void setNumber(String number) {
this.number = number;
public String getNumber() {
return number;
public void setLocationTest(LocationTest bd) {
this.location = bd;
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(location);
f.getContentPane().add(location.getControls(), "Last");
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
public LocationTest getLocationTest() {
return location;
}[3].
package test.temp;
import java.io.Serializable;
public class Person implements Serializable{
private String fullname;
@SuppressWarnings("unused")
private PhoneNumber phone;
@SuppressWarnings("unused")
private PhoneNumber fax;
public Person(){
public Person(String fname){
fullname=fname;
public void setPhone(PhoneNumber phoneNumber) {
phone = phoneNumber;
public void setFax(PhoneNumber phoneNumber) {
fax = phoneNumber;
public PhoneNumber getPhone() {
return phone ;
public PhoneNumber getFax() {
return fax;
public String getName() {
return fullname ;
public void setName(String name) {
this.fullname = name;
public String toString() {
return getName();
}[4]. LocationTest.java
package test.temp;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
public class LocationTest extends JPanel implements ChangeListener
Ellipse2D.Double ball;
Line2D.Double line;
JSlider translate;
double lastTheta = 0;
public void stateChanged(ChangeEvent e)
JSlider slider = (JSlider)e.getSource();
String name = slider.getName();
int value = slider.getValue();
if(name.equals("rotation"))
tilt(Math.toRadians(value));
else if(name.equals("translate"))
moveBall(value);
repaint();
protected void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if(ball == null)
initGeom();
g2.setPaint(Color.green.darker());
g2.draw(line);
g2.setPaint(Color.red);
g2.fill(ball);
private void initGeom()
int w = getWidth();
int h = getHeight();
int DIA = 30;
int padFromEnd = 5;
line = new Line2D.Double(w/4, h*15/16, w*3/4, h*15/16);
double x = line.x2 - padFromEnd - DIA;
double y = line.y2 - DIA;
ball = new Ellipse2D.Double(x, y, DIA, DIA);
// update translate slider values
int max = (int)line.getP1().distance(line.getP2());
translate.setMaximum(max);
translate.setValue(max-padFromEnd);
private void tilt(double theta)
// rotate line from left end
Point2D pivot = line.getP1();
double lineLength = pivot.distance(line.getP2());
Point2D.Double p2 = new Point2D.Double();
p2.x = pivot.getX() + lineLength*Math.cos(theta);
p2.y = pivot.getY() + lineLength*Math.sin(theta);
line.setLine(pivot, p2);
// find angle from pivot to ball center relative to line
// ie, ball center -> pivot -> line end
double cx = ball.getCenterX();
double cy = ball.getCenterY();
double pivotToCenter = pivot.distance(cx, cy);
// angle of ball to horizon
double dy = cy - pivot.getY();
double dx = cx - pivot.getX();
// relative angle phi = ball_to_horizon - last line_to_horizon
double phi = Math.atan2(dy, dx) - lastTheta;
// rotate ball from pivot
double x = pivot.getX() + pivotToCenter*Math.cos(theta+phi);
double y = pivot.getY() + pivotToCenter*Math.sin(theta+phi);
ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
lastTheta = theta; // save theta for next time
private void moveBall(int distance)
Point2D pivot = line.getP1();
// ball touches line at distance from pivot
double contactX = pivot.getX() + distance*Math.cos(lastTheta);
double contactY = pivot.getY() + distance*Math.sin(lastTheta);
// find new center location of ball
// angle lambda = lastTheta - 90 degrees (anti-clockwise)
double lambda = lastTheta - Math.PI/2;
double x = contactX + (ball.width/2)*Math.cos(lambda);
double y = contactY + (ball.height/2)*Math.sin(lambda);
ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
JPanel getControls()
JSlider rotate = getSlider("rotation angle", "rotation", -90, 0, 0, 5, 15);
translate = getSlider("distance from end", "translate", 0, 100, 100,25, 50);
JPanel panel = new JPanel(new GridLayout(0,1));
panel.add(rotate);
panel.add(translate);
return panel;
private JSlider getSlider(String title, String name, int min, int max,
int value, int minorSpace, int majorSpace)
JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, value);
slider.setBorder(BorderFactory.createTitledBorder(title));
slider.setName(name);
slider.setPaintTicks(true);
slider.setMinorTickSpacing(minorSpace);
slider.setMajorTickSpacing(majorSpace);
slider.setPaintLabels(true);
slider.addChangeListener(this);
return slider;
}OK, My questions are:
[1]. what I generated XML by XSTream is very complicated, especially for object LocationTest, Can we make it as simple as others such as Person object??
[2]. after I run it, LocationTest will popup and a red ball in a panel will dsiplay, after I change red ball's position, I hope to persist it to xml, then when I read it back, I hope to get same picture, ie, red ball stiil in old position, How to do that??
Thanks a lot!!Positive feedback? Then please take this in a positive way: if you want to work on persisting Java objects into XML, then GUI programming is irrelevant to that goal. The 1,000 lines of code you posted there appeared to me to have a whole lot of GUI code in it. You should produce a smaller (much smaller) example of what you want to do. Calling the working code from your GUI program should come later.
-
How can one use Mission Control with two monitors? Please bring Spaces back
How can one use Mission Control with two monitors. With Spaces I could treat each space as a single desktop.
SyBBI use two monitors at work and have no issue. I have my mail set to use Desktop 1 and iTunes set to the second monitor of Desktop 1. I have browsers set to Desktop 2 and Fusion and RDC set to Desktop 3.
Two things that may help you. In System Preferences > Mission Control, disable the setting "Automatically rearrange spaces...". This screwed with assigning applications to certain spaces. And the other thing is don't use full screen on apps that support it. This just makes your second monitor superfluous. -
How can we use the standard LDB in custom program.
Dear all,
can you please tell me the way , how can we use the standard LDB in custom program.
Thanks & Regards,
Jyothi.Hi
You can use the Function module LDB_PROCESS to use the Standard LDB in your Z custome program for further details about using the Standard LDB and accessing the LDB in to the program search SDN
http://help.sap.com/saphelp_nw04/helpdata/en/64/237f8cd43711d1950b0000e8353423/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/97/b3edb8163111d2953c0000e8353423/frameset.htm -
How can we store xml data using jsp
hai,
Can anyone please explain in brief how to store xml data using jsp. Also if possible please explain by specifying the code.
regards,
Praveen Vinnakota.[email protected] wrote:
how can we publish Labview data using the web?
You could use shared variables and publish them to the network or use data sockets.
Kudos always welcome for helpful posts -
How to get & use xml data with jstl libraries? (URGENT PLZ)
I am using jstl to get and use xml data
I needs to perform operations on the parsed xml document with other libraries of jstl. How can i do that.
I used Dom variable to parse my document as:
<x:parse varDom="test"> <c:import url="project.xml"/> </x:parse>
where my project.xml is:
<?xml version="1.0" encoding="iso-8859-1"?>
<project> <projectName>myProject</projectName> </project>
I can dislay this value in html by
<x:out select="$test/project/projectName"/>
But I need a string value sotred in variable such as <c:set var="pname" value="???">
HOW CAN I SET THIS VALUE IN CORE VARIABLE THAT IS, USING <c:set...> SO THAT IT CAN BE USED ANYWHERE IN JSP PAGE TO CONCATE RETURNED STRING IN OTHER STRING VARIABLES DEFINED BY CORE LIB?
Jessy
Message was edited by:
jessy
Message was edited by:
jessyI believe that <c:set> should do that but i am facing problem in it. Look into this jsp scriptlet:
1-<x:parse varDom="test"> <c:import url="project.xml"/> </x:parse>
2-<x:set var="ds" select="$test/project/projectName"/>
3-<x:out select="$ds"/> <br>
4-<c:set var="tt" value="${ds}" />
5-<c:out value="${tt}" />
In line 3 variable ds returns: myProject
In line 5 variable tt returns: [[projectName: null]]
perhaps on line 4 ds is storing some array to tt and i am not calling correct array element. I tried many options but still could not find solution. Plz Plz do something urgent for me. Thanks
Jessy
Message was edited by:
jessy -
Can't import XML data into my databse-connected PDF form
Hi All
Excellent forum, and thanks for all the revealing insights so far viewed, however one question.I'm using a PDF form to collect info via email in the format of XML datafiles. I also have an identical PDF which has database connectivity and that works fine. It was suggested on this forum that I could then import the XML data into my Database via the DB-connected PDF, in effect a user form and one with DB connectivity. Now, I've checked the data types and they all match, but when I import XML file, it creates a blank record in the database and none of the information is carried through. Please could someone offer guidance on what I'm doing wrong, I've been trying to figure this out for a week now?
Thanks
SteppeMaybe it's because I'm replying by email, so I'll try the forums directly;
</script>
</event>
<assist>
<toolTip>Click to delete the current record fromthe database</toolTip>
<speak priority="toolTip"/>
</assist>
</field>
<field name="Decam_Done" y="44.45mm" x="165.1mm" w="28.575mm" h="13.707mm">
<ui>
<textEdit>
<border>
<?templateDesigner StyleID aped3?>
<edge stroke="lowered"/>
</border>
<margin/>
</textEdit>
</ui>
<font typeface="Myriad Pro"/>
<margin topInset="1mm" bottomInset="1mm" leftInset="1mm" rightInset="1mm"/>
<para vAlign="middle"/>
<caption reserve="4.2353mm" placement="top">
<font typeface="Myriad Pro"/>
<para vAlign="middle"/>
<value>
<text>Decam_ Done</text>
</value>
</caption>
<border>
<edge/>
<corner thickness="0.175mm" join="round" radius="2mm"/>
</border>
<bind match="dataRef" ref="$.Decam_Done"/>
<validate nullTest="error"/>
</field>
<?templateDesigner expand 1?></subform>
<proto/>
<desc>
<text name="version">8.2.1.3144.1.471865.466429</text>
</desc>
<?templateDesigner expand 1?></subform>
<?templateDesigner DefaultLanguage FormCalc?>
<?templateDesigner DefaultRunAt client?>
<?acrobat JavaScript strictScoping?>
<?templateDesigner Grid show:0, snap:1, units:0, color:ff8080, origin:(0,0), interval:(125000,125000)?>
<?templateDesigner FormTargetVersion 26?>
<?templateDesigner Zoom 75?>
<?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?>
<?templateDesigner SaveTaggedPDF 1?>
<?templateDesigner SavePDFWithEmbedded -
This has been incredibly frustrating. I am in the middle of a trip to Europe. Before I left, I confirmed with VZW CSR's that my s3 LTE phone is fully unlocked and that I could buy a local sim and use it while in Austria.
Aside -- I can't use VZW global services on their network -- cost notwithstanding -- because I hit some device limit when I bought my wife an iPad, and VZW required a deposit for it. No big deal, EXCEPT that here three months later I learn that VZW accounting prohibits global roaming if you account has a deposit. So fine, VZW doesn't want me to pay them a dollar a minute and $20/100MB. No problem, I can get a drei (3) prepaid card for 10 euros that has 1000 minutes and 2 GB of data.
So, I do. I activate the card, and voice and sms work fine. No data. No joy.
Step 1. I call samsung. Samsung, after about an hour of claiming it should work, decides that it is because VZW has some sort of software block. Not surprising, since the software is actually from VZW.
Step 2. Call VZW. After a great deal of **** VZW says you have to go back to the drei store.
Step 3. Return to drei. Store rep discovers VZW software will not recognize their access point name (APN), and will not let you enter it. They verify on a different s3 that the sim is fine. With my VZW sim, I can see the VZW APN's, but because I don't have global services turned on, no joy.
Step 4. Do some web digging. Discover that this APN thing is a known bug. Web sites (like the CSR in the transcript) suggest rooting or jailbreaking is the only workaround -- which I don't want to do. But here I sit in Austria, with no data on a top of the line VZW phone and an account with seven different lines.
So, how do I resolve this? Take the phone back, because there is clearly a defect? But if it's software, I'll have to get an escalation to get a different phone. Is there a fix? Sue for false advertising? Better yet, start a class action -- there sure seem to be a lot of us in this boat based on web searches.
<< Transcript removed to comply with Verizon Wireless Terms of Service >>
Message was edited by: Verizon ModeratorOK, I have to throw VZW some props here. I went to the store where I bought my phones, and explained the problem I was having with international travel and the s3. The store put me into an iphone5 for free as a warranty exchange -- apparently they know the APN issue is a serious one and they said there was a big lawsuit about it. It cost me a bit for power adapters and such, and a few paid apps, but the iphone has (reportedly) no issues with international travel and local sims.
Way to go, VZW. Mark this one up for responsive customer service. -
How to insert large xml data into database tables.
Hi all,
iam new to xml. i want to insert data in xml file to my database tables.but the xml file size is very large. performance is also one of the issue. can anybody please tell me the procedure to take xml file from the server and insert into my database tables.
Thanks in advanceUnfortunately posting very generic questions like this in the forum tends not to be very productive for you, me or the other people who read the forum. It really helps everyone if you take a little time to review existing posts and their answers before starting new threads which replicate subjects that have already been discussed extensively in previous threads. This allows you to ask more sensible questions (eg, I'm using this approach and encountering this problem) rather than extremely generic questions that you can answer yourself by spending a little time reviewing existings posts or using the forum's search feature.
Also in future your might want to try being a little more specific before posting questions
Eg Define "very large". I know of customers who thing very large is 100K, and customers who think 4G is medium. I cannot tell from your post what size your files are.
What is the content of the file. Is it going to be loaded into a single record, or a a single table, or will it need to be loaded into multiple records in a single table or multiple records in multiple tables ?
Do you really need to load the data into exsiting relational tables or could your application work with relational views of the XML Content.
Finally which release of the database are you working with.
Define performance. Is it reasonable to expect to process this kind of document on this machine (Make, memory, #number of CPUs, CPU Speed, number of discs) in this period of time.
WRT to your original question. If you take a few minutes to search this forum you will find a very large number of threads with very similar titles to yours. These theads document a number of different approaches that can be used to solve this problem.
I suggest you start by looking for threads that cover topics like DBMS_XMLSTORE, XMLTable(), Relational Views of XML content, loading XML content in relational tables. -
How can I embed XML data in a PDF?
I want to embed XML data in a PDF so the file can be scanned for the data behind the document. Is there a standard way to do this?
For example, if the PDF is a bank statement, the embedded XML would be the individual's account number and bank balances. It would not include any of the standard text in the statement such as the bank name, etc.
I've read up on the XMP spec but that seems to be more metadata about the document (title, subject, etc.). And there is tagged content but that is an alternate view of the entire document.
??? - thanks - daveAlthough the XMP block is stored in XML, you can't just embed any XML file. The block has to follow the standard, which means that each data packet needs to be defined in a schema - as the name suggests, XMP is eXtendable so you can define new schema for local use, but you can't mess about with the standard ones and randomly add new tags. The schema itself isn't embedded in the file, it's referenced by a unique ID and URI. of course having a data packet in a custom schema doesn't mean any software will see it - Acrobat's Advanced Search can be told to scan the XMP block but search engines only tend to bother with the basic tags such as 'title' and 'description'.
To see what's currently in a PDF, open Document Properties > Description > Additional Metadata > Advanced.
You can save the current XMP block as a text file (.xmp extension), and replace/append other XMP files. If you click the "i" icon on the top right of the Advanced dialog you can access system profiles - these can be created in other applications such as Bridge, but there's no profile manager in Acrobat itself.
For technical information on working with XMP and creating new schema, see http://www.adobe.com/devnet/xmp.html
Note that the XMP SDK for CS6 does not work in the Acrobat Family. -
How to Store an XML Data into Table?
Hi All,
My Requirement is "I Have an XML File (or) XML Data as CLOB, now I should decode this XML Data and find the equivalent data for columns in a table and then store that in a relational table",
Would be greatful if any one can provide me a feasible solution (or) good link where I can get this information with examples.
Thanks in advance,
Sunil NOr,
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Elapsed: 00:00:00.03
satyaki>
satyaki>
satyaki>drop table dump_tab;
Table dropped.
Elapsed: 00:00:01.08
satyaki>
satyaki>create table dump_tab
2 (
3 raw_xml clob
4 );
Table created.
Elapsed: 00:00:00.00
satyaki>
satyaki>
satyaki>desc dump_tab;
Name Null? Type
RAW_XML CLOB
satyaki>
satyaki>
satyaki>insert into dump_tab
2 select yy.rxml
3 from (
4 select (' <data>
5 <var name="document">
6 <string>Sales Order</string>
7 </var>
8 <var name="results">
9 <recordset rowcount="2">
10 <field name="sales_num">
11 <string>12345</string>
12 <string>60192</string>
13 </field>
14 <field name="ord_qty">
15 <string>10</string>
16 <string>50</string>
17 </field>
18 </recordset>
19 </var>
20 </data>'
21 ) rxml from dual
22 ) yy;
1 row created.
Elapsed: 00:00:00.00
satyaki>
satyaki>commit;
Commit complete.
Elapsed: 00:00:00.00
satyaki>
satyaki>create table results
2 (
3 serial_no number(5),
4 sales_num number(7),
5 ord_qty number(10)
6 );
Table created.
Elapsed: 00:00:00.00
satyaki>
satyaki>desc results;
Name Null? Type
SERIAL_NO NUMBER(5)
SALES_NUM NUMBER(7)
ORD_QTY NUMBER(10)
satyaki>
satyaki>select * from dump_tab;
RAW_XML
<data>
<var name="document">
<string>Sales Order</string>
</var>
<var name="results">
<recordset rowcount="2">
<field name="sales_num">
<string>12345</string>
<string>60192</string>
</field>
<field name="ord_qty">
RAW_XML
<string>10</string>
<string>50</string>
</field>
</recordset>
</var>
</data>
Elapsed: 00:00:00.01
satyaki>
satyaki>
satyaki>ed
Wrote file afiedt.buf
1 insert into results(serial_no,sales_num,ord_qty)
2 with t
3 as (
4 select xmltype(raw_xml) xml from dump_tab
5 ),
6 t1 as (select rownum rn, t1.column_value.extract('*/text()') sales_num from t t, table(xmlsequence(t.xml.extract('//field[@name="sales_num"]/string'))) t1),
7 t2 as (select rownum rn, t2.column_value.extract('*/text()') ord_qty from t t, table(xmlsequence(t.xml.extract('//field[@name="ord_qty"]/string'))) t2)
8 select t1.rn x,
9 to_number(regexp_replace(xmlelement("e",sales_num).getstringval(),'<(|/)e>','')) sales_num
10 to_number(regexp_replace(xmlelement("d",ord_qty).getstringval(),'<(|/)d>','')) ord_qty
11 from t1,t2
12* where t1.rn = t2.rn
satyaki>/
2 rows created.
Elapsed: 00:00:00.00
satyaki>
satyaki>select * from results;
SERIAL_NO SALES_NUM ORD_QTY
1 12345 10
2 60192 50
Elapsed: 00:00:00.00
satyaki>Regards.
Satyaki De. -
How can I get xml data from KM?
Hi guys,
how can i get a xml data from KM?
I saved an xml document in KM, and I want to read its content. How can I get this document?
Using
DocResource = (IResource) resFactory.getResource(RID.getRID("Document/ Path"),resContext)?
I want to know which kinds of API of KM are responsible for this.
Thanks in advance
Regards,
LiyingHi Liying
use this code.
try {
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
IUser sapUser = wdClientUser.getSAPUser();
com.sapportals.portal.security.usermanagement.IUser ep5User =
WPUMFactory.getUserFactory().getEP5User(sapUser);
IResourceContext resourseContext = new ResourceContext(ep5User);
IResourceFactory resourseFactory = ResourceFactory.getInstance();
RID pathRID =
RID.getRID(
"/documents/"(Path to folder where ur file is"");
ICollection collection =
(ICollection) resourseFactory.getResource(
pathRID,
resourseContext);
IResourceList resourceList = collection.getChildren();
IResourceListIterator resourceListIterator =
resourceList.listIterator();
while (resourceListIterator.hasNext()) {
com.sapportals.wcm.repository.IResource resource =
resourceListIterator.next();
try {
/*File from KM Reading*/
InputStream in = resource.getUnfilteredContent().getInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int bytesread = 0;
while ((bytesread = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesread);
String dataToBeConvertedToXML = out.toString();
catch(Exception e){}
catch(Exception e){}
Award points if found usefull.
I suppose you have used KM sharing reference in ur application
Regards
BP
Maybe you are looking for
-
Venda de Serviços com valor de ISS no Gross Up
Olá pessoal, uma dúvida. O cliente vende exclusivamente serviços, apliquei as notas 1706309, 664855, 747670, 852302, 916003 e 815720. Efetuei testes para Cofins e Pis e está calculando muito bem. Porém o erro está no cálculo do ISS quando utilizado o
-
Hi all, I have done file to idoc scenario. in that No error in sxmb_moni IN SAP system( we05) EDI: Partner profile inbound not available Status 56 Message from Control records is-> patner Recipient Information (EMPTY) IDS47800 LS Sender Information
-
Hello Experts, I have a requirement of generating Night Shift Premium Hours. My Night Shift is from 18:30 to 6:30. Where as Hours needs to consider for Night Premium is only between 21:00 to 5:00. We are having Positive Time scenerio & Clock in/out i
-
Sophos Antivirus version 10 or higher not included in PRUs?
Hello Novell-Forums. My request regards an update for the ZCMs PRUs in order to discover Sophos Antivirus version 10 or higher. At the moment the Asset Management discovers Sophos only up to version 9,5. All higher Sophos-versions are to be found wit
-
BEx Analyzer - Aggregation of Negative and Positive Values
Hello Gurus, I have a key figure 0Subtotal1. This KF contains both negative and positive figures. For eg; +10, -20, -30. In Query Analyzer, I need the column total as 60 and not -40. Can I use a formula and use the ABS function... Any clue.... thanks