How to write data to xml file?

Hi,
I have done a project which read data from a web then write in log file.
Now i want to write data in xml file.
how to write?
i read some java and xml tutorial, quite quite difficult.
Who can give a simple example with some comments?
If you also give some tips on learning java web services, i will be very appreciated.
Thanks
Yang Bin

Choose Xerces2.4 to serialize the DOM object is an option.
javac XercesTest.java -classpath xmlParserAPIs.jar;xercesImpl.jar;.
java -classpath xmlParserAPIs.jar;xercesImpl.jar;. XercesTest test.xml
below is the source file: XercesTest.java
//JAXP
import javax.xml.parsers.*;
import org.w3c.dom.*;
//APACHE SERIALIZE FUNCTION
import org.apache.xml.serialize.*;
class XercesTest
public static void main(String[] args) throws Exception
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse( new File( args[0] ) );
File f = new File( "copy_of_"+ args[0] );
OutputFormat format = new OutputFormat("xml","UTF-8",true ) ;
FileOutputStream fout = new FileOutputStream( f );
XMLSerializer ser = new XMLSerializer(fout, format );
ser.serialize( doc );
hope it's helpful
land

Similar Messages

  • 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
    Nagaraju

    This 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 write data to text file using external tables

    can anybody tell how to write data to text file using external tables concept?

    Hi,
    Using external table u can load the data in your local table in database,
    then using your local db table and UTL_FILE pacakge u can wrrite data to text file
    external table
    ~~~~~~~~~~~
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2153251
    UTL_FILE
    ~~~~~~~~~
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#sthref14093
    Message was edited by:
    Nicloei W
    Message was edited by:
    Nicloei W

  • How to write and read Xml file from database if possible?

    Hi all,
    I need to read the .Xml file when receives from Source systems and write the data into the table as well as write in the.xml file thru reading the data from table as per the client needs. I am stranger to this area. Since, please provide some examples how to approach the same.
    Thanks in advance !!
    Regards.
    Vissu.....

    The XML DB forum is better suited to your question.
    It also has a FAQ which details how to read and shred XML into tables as well as other common XML based questions...
    XML DB FAQ

  • How to add data in xml file

    Hi ALL
    I want to add new fields on seeded EBS page to store their values in hr_api_transaction table whoch contain information of other fields on that page which are seeded
    but that table has one column which stores xml file and that xml file has all information about that page's fields
    how can I store my custom fields values in that xml file ?

    Hi,
    As Andy said,  add data to an xml file is overwriting, if you mean append data to xml file, please look this article:
    http://codesamplez.com/programming/linq-to-xml-tutorial, Since this issue is more related to ASP.net, you could also ask this issue in asp.net forum:
    http://forums.asp.net/
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to Write data in Excel File using java

    Hi
    can anybody help me to write data in excel file
    using java code
    Thankx In Advance

    How much are you willing to pay for that?
    If you want it for free, http://jexcelapi.sourceforge.net/

  • How to write to an XML file from JDE batch application?

    Hello everyone,
    I need to write data from a batch application to an XML file. I don't know how to use the XML business functions.
    I tried to use XML Publisher but the format is not the same as the client XML. The XML file has some customized format.
    I need to do it manually with business functions and ER. Please help me out.
    Some business functions I saw are Create XML document, XML Add element and XML Add attribute but the parameters are complex to
    use.
    Thank you very much.
    Edited by: Lovvy on Sep 8, 2010 2:58 AM

    The XML DB forum is better suited to your question.
    It also has a FAQ which details how to read and shred XML into tables as well as other common XML based questions...
    XML DB FAQ

  • How to retrieve data from xml file into obiee reports

    Hi all,
    I've got a situation here. A xml file is stored as blob in oracle database table. Now i need to retrieve data/info from that xml file into obiee reports. How am i supposed to proceed with this ?

    I will go for a table function:
    http://gerardnico.com/wiki/database/oracle/table_function
    In two words, you can create a function that behave as a table. Then you create a function to pick up your xml, you parse it and you send back the rows.
    I know that Oracle has also a library for XML files but I never use it until now.
    Success
    Nico

  • How to write POJO for XML file.. i do not want to use JAXB or any other tec

    How to generate POJOs for the specific xml files.
    Each XML file will have elements name with Type. Which in turn related to some other xml file
    For example
    student.xml
    <student name"mystudent">
    <studentname type="firstname"/>
    <studentname type="firstname"/>
    <studentname type="firstname"/>
    </student>
    firstname.xml
    <studentname name="firstname">
    <stufirstname type="myfirstname"/>
    </studentname>
    myfirstname.xml
    <myfirstname name="myfirstname">
    <myname1>xxx</myname1>
    </myfirstname>
    like this there will be so many xml files interlinked.
    I would like to write POJOs for these xml files
    please let me know what is the best way to write (design the hirarchy of these xml files
    Thanks in advance
    srinivas

    Not at this time. You may submit your polite feedback to Apple using this webpage: http://www.apple.com/feedback/itunesapp.html

  • How to fetch data into xml file trom sql table.

    Hi,
    We r now working in oracle 9iAS portal.
    We have installed xdk along with 9iAS.
    I would like to know how to and where to run an xsql file,preferably with an example to fetch data from a database table to a xml file.

    Please download the latest version of XDK for Java at:
    http://otn.oracle.com/tech/xml/xdk_java
    In the downloaded package, there are demos for XSQL Servlet. The demo "emp" and "empdept" are good start.

  • How to extract data from xml file in owb 10.2?

    I have to load data from an xml file into a relational table , may i know how to do it in owb 10.2.

    This 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 data from xml file and store that data inti data base table

    Hii All
    I have one table that table contains one column that column contain an XML file
    I want to extract data from that XML file and want to store that extracted data into an other table.
    That xml file has different different values
    I want to store that values into table in diff diff columns

    Hi,
    I am also facing the same problem.I have a .xml file and i need to import the data into the custom table in oracle database.
    Can you please let me know if you know the solution how to do it in oracle apps.
    Thanks,

  • How to write data to existing file using spool command?

    Hi,
    I am calling a stored procedure from a shell script. This stored procedure is having a CLOB object as an OUT parameter. How to write the data in CLOB object a existing file which is there in my client system. Below is the shell and sql scripts.
    Shell script
    ( echo "hello" ) > /root/file.txt
    sqlplus -s $user/$pass@$tns @/root/proc.sql /root/file.txt << EOF
    EOFSQL script
    set pages 0
    set trimspool off
    set serveroutput off
    set feedback off
    set term off
    set echo off
    variable out CLOB
    define file='&1'
    begin
    pack.proc(:out);
    end;
    spool &file
    select :out from dual;
    spool offThis code writes contents of the OUT variable to file.txt, but my existing data ('hello') is lost. Please help me.
    I figured the it...Use append in the spool command... :)
    Edited by: Balaji on Jul 19, 2012 8:55 PM

    >
    Hi Balaji
    I figured the it...Use append in the spool command... :Please mark the thread as answered as per the FAQ.
    Paul...

  • How to write data into xml through web service

    Hi,
      I have a requirement to write the data into xml through a web service .send me related links and sample code if any.

    hi kiran,
      write the data into xml : We need suitable set of java Beans for handling WebService Data.
       However, there are cases when you may prefer an alternate mapping, or when there just isn't a well-defined mapping for your particular schema construct (xsd:choice is a common example). For these cases, IBM® WebSphere® has introduced a new feature called Custom Data Binding that allows you to integrate alternate data binding technologies like JAX-B, EMF/SDO and XML beans, as well to define your own XML schema to Java mappings. This article provides an overview of the technology and how you can get started integrating it into your application.
    GO THru THis Links :
    http://www-128.ibm.com/developerworks/websphere/library/
    techarticles/0601_gallardo/0601_gallardo.html.
    Hope It Helps.
    Thanks
    Varun CN

  • How to write data into a file

    Hi
    I want to write data from a string into a file. I am created a directory and a .doc file . But when i write this data from a string into .doc file , its give an error : File not found exception
    But, when i check in my directory, a file is created with blank.
    My code is:
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    class createFile {
         public static void main(String[] args) {
    try {
         String mss = "This is for dedo";
         FileInputStream fis;
         FileOutputStream fos;
    File file = new File("C:\\JD\\m4.rtf");
    // Create file if it does not exist
    boolean success = file.createNewFile();
         success = true;
    if (success) {
                   System.out.println("suc");     
                   fis = new FileInputStream(mss);
                   System.out.println(fis);
              fos = new FileOutputStream(file);
              int c;
                   while ((c = fis.read()) != -1) {
         fos.write(c);
                   System.out.println("mss");
              fis.close();
              fos.close();
         System.out.println("created");
    // File did not exist and was created
    } else {
    // File already exists
    } catch (IOException e) {
         System.out.println(e);
    regards
    madhu

    InputStream inputStream = new ByteArrayInputStream(mss.getBytes());Use this to push into the file>
    Ummm.... no. InputStreams are for reading, not for writing.
    Anyway, OP, you're making a mistake. You're trying to open a stream to a file called "This is for dedo". Use FileOutputStream(File file) constructor or FileOutputStream(String pathToFile). You can then wrap that stream with a PrintWriter or whatever you need.

Maybe you are looking for

  • First attempt at a package - rstudio-desktop-preview

    Hi all - I've been interested in providing a package for the preview release of RStudio for quite some time now and I figured that I might as well just give it a shot - what's the worst that could happen.  I read through some of the threads but I gue

  • SOA 11.1.1.4 installation on Weblogic 10.3.5

    I have seen that each SOA suite is supported by one particular version of weblogic server. Like 11.1.1.2 with 10.3.2 11.1.1.4 with 10.3.4 11.1.1.5 with 10.3.5 But is it possible to install earlier version of SOA suite i.e. 11.1.1.4 on advance version

  • RoboHelp unable to start word

    Using RoboHelp 7 & Word 2003 (service packs installed) on XP. I try to open an old project RoboHelp 6. Word Starts. However after a long period of time I get a dialog box saying: 'RoboHelp Explorer is unable to start Microsoft Word'. Bit of a show st

  • Can't sync after computer upgrade

    Hi, Friday night I got a new MacBook pro. Yesterday I used the transfer function to move all of my files from my old MacBook to the new one. This morning, I can't sync my iPad. My iPod does sync, so it isn't the ports on the MacBook or the cables. I

  • How Do I convert image in xml data file back into a JPG?

    I have a user submitted for with an image field and some text fields on it. User uploads an image, enters text, clicks submit by email. I get the xml data file by email. I create a spreadsheet from it. text field data is there, in the image field col