REG: WRITE XML STRING INTO XML FILE

Hi All, I have a XML FILE on PC. I get a xml string from my server.
My Task: I want to append the xml string coming from the server into the existing xml file at a particular Node. Given below is my code :
String xmlString = baos.toString();
                  DocumentBuilder db4XMLString = docBuilderFactory.newDocumentBuilder();
                  InputSource inStream = new InputSource();
                  inStream.setCharacterStream(new StringReader(xmlString));
                  Document doc4XMLString = db4XMLString.parse(inStream);
                  Node root4XMLString = doc4XMLString.getElementsByTagName("epg").item(0);
                  doc.appendChild(doc.importNode(root4XMLString, true));
                  File file = new File(Constant.XMLFILEPATH);
                  Result result = new StreamResult(file.toURI().getPath());
                  Source source = new DOMSource(doc);
                  Transformer xformer = TransformerFactory.newInstance().newTransformer();
                  xformer.transform(source, result);But, wen i run my application I get following exception:
The markup in the document following the root element must be well-formed.
org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
Is that my XML string is not well formed. Is it so then please let me how to convert my xml string into well formed XML data.
Please help me out.
Thanking You.

There are many reasons why xmlString could be not well formed. There is no magic recipe for making it well formed: just look at it and see why it is not parseable.
Note that this line:
String xmlString = baos.toString();can be problematic if you have non ASCII-7 characters in your XML document. baos could then contain a byte representation of these characters in one particular encoding, but, since you use the .toString() method that relies on the default encoding of your system, you can end up with a mismatch and garbage in your XML.

Similar Messages

  • How to write a string into a file in java

    Say i hv a string named str.......plz give the total code of creating a file and writing the string into it

    This is the function where i am trying to write a file....i hv highlighted the regions where file writing codes are used........kindly suggest where is my mistake as this code is running but not writing anything.........only the file is getting created but nothing is getting written...aslo i havnt put fw.close() here where in the code should I put it
    static void func1(String str) throws IOException
    int i=0,j=0,k=1,m=0;
    int size1=0,file_size=0;
    String str1;
    int arr[]= new int[no_of_lines+1];
    FileWriter fw;
    *try{*
    fw=new FileWriter("output.txt");
    catch(IOException exc)
    System.out.println("Cannot open file");
    return;
    arr[0]=0;
    while(true)
    a=svcRand.nextInt(10);
    k++;
    i=0;
    j++;
    try{
    FileReader fr= new FileReader(str);
    BufferedReader br= new BufferedReader(fr);
    while((str1=br.readLine()) !=null)
    i++;
    if(i==a)
    file_size=func2(str1,size1);
    str1=str1+"\r\n";
    fw.write(str1);
    catch(FileNotFoundException exc)
    System.out.println("File not found");
    return;
    catch(ArrayIndexOutOfBoundsException exc)
    System.out.println("Usage: Showfile file");
    return;

  • How to read and write a string into a txt.file

    Hi, I am now using BEA Workshop for Weblogic Platform version10. I am using J2EE is my programming language. The problem I encounter is as the above title; how to read and write a string into a txt.file with a specific root directory? Do you have any sample codes to reference?
    I hope someone can answer my question as soon as possible
    Thank you very much.

    Accessing the file system directly from a web app is a bad idea for several reasons. See http://weblogs.java.net/blog/simongbrown/archive/2003/10/file_access_in.html for a great discussion of the topic.
    On Weblogic there seems to be two ways to access files. First, use a File T3 connector from the console. Second, use java.net.URL with the file: protocol. The T3File object has been deprecated and suggests:
    Deprecated in WebLogic Server 6.1. Use java.net.URL.openConnection() instead.
    Edited by: m0smith on Mar 12, 2008 5:18 PM

  • How can i write a string into a specified pos of a file?

    How can i write a string into a specified pos of a file without read all file into ram and write the whole file again?
    for example:
    the content of file is:
    name=123
    state=456
    i want to modify the value of name with 789
    (write to file without read all file into ram)
    How can i do it? thank you

    take this as an idea. it actually does what i decribed above. you sure need to make some modifications so it works for your special need. If you use it and add any valuable code to it or find any bugs, please let me know.
    import java.io.*;
    import java.util.*;
    * Copyright (c) 2002 Frank Fischer <[email protected]>
    * All rights reserved. See the LICENSE for usage conditions
    * ObjectProperties.java
    * version 1.0, 2002-09-12
    * author Frank Fischer <[email protected]>
    public class ObjectProperties
         // the seperator between the param-name and the value in the prooperties file
         private static final String separator = "=";
         // the vector where we put the arrays in
         private Vector PropertiesSet;
         // the array where we put the param/value pairs in
         private String propvaluepair[][];
         // the name of the object the properties file is for
         public String ObjectPropertiesFileName;
         // the path to the object'a properties file
         public String ObjectPropertiesDir;
         // reference to the properties file
         public File PropertiesFile;
         // sign for linebreak - depends on platforms
         public static final String newline = System.getProperty("line.separator");
         public ObjectProperties(String ObjectPropertiesFileName, String ObjectPropertiesDir, ObjectPropertiesManager ObjectPropertiesManager)
         //     System.out.println("Properties Objekt wird erzeugt: "+ObjectPropertiesFileName);
              this.ObjectPropertiesFileName = ObjectPropertiesFileName;
              this.ObjectPropertiesDir = ObjectPropertiesDir;
              // reference to the properties file
              PropertiesFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
              // vector to put the param/value pair-array in
              PropertiesSet = new Vector();
         //     System.out.println("Properties File Backup wird erzeugt: "+name);
              backup();
         //     System.out.println("Properties File wird eingelesen: "+PropertiesFile);
              try
                   //opening stream to file for read operations
                   FileInputStream FileInput = new FileInputStream(PropertiesFile);
                   DataInputStream DataInput = new DataInputStream(FileInput);
                   String line = "";
                   //reading line after line of the properties file
                   while ((line = DataInput.readLine()) != null)
                        //just making sure there are no whitespaces at the beginng or end of the line
                        line = cutSpaces(line);
                        if (line.length() > 0)
                             //$ indicates a param-name
                             if (line.startsWith("$"))
                                  // array to store a param/value pair in
                                  propvaluepair = new String[1][2];
                                  //get the param-name
                                  String parameter = line.substring(1, line.indexOf(separator)-1);
                                  //just making sure there are no whitespaces at the beginng or end of the variable
                                  parameter = cutSpaces(parameter);
                                  //get the value
                                  String value = line.substring(line.indexOf(separator)+1, line.length());
                                  //just making sure there are no whitespaces at the beginng or end of the variable
                                  value = cutSpaces(value);
                                  //put the param-name and the value into an array
                                  propvaluepair[0][0] = parameter;
                                  propvaluepair[0][1] = value;
                             //     System.out.println("["+ObjectPropertiesFileName+"] key/value gefunden:"+parameter+";"+value);
                                  //and finaly put the array into the vector
                                  PropertiesSet.addElement(propvaluepair);
              // error handlig
              catch (IOException e)
                   System.out.println("ERROR occured while reading property file for: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
                   // System.out.println("in ObjectProperties");
         // function to be called to get the value of a specific paramater 'param'
         // if the specific paramater is not found '-1' is returned to indicate that case
         public String getParam(String param)
              // the return value indicating that the param we are searching for is not found
              String v = "-1";
              // looking up the whole Vector
              for (int i=0; i<PropertiesSet.size(); i++)
                   //the String i want to read the values in again
                   String s[][] = new String[1][2];
                   // trying to get out the array from the vector again
                   s = (String[][]) PropertiesSet.elementAt(i);
                   // comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
                   if (s[0][0].equals(param) == true)
                        //if the param-names are the same, we look up the value and write it in the return variable
                        v = s[0][1];
                        // making sure the for loop ends
                        i = PropertiesSet.size();
              // giving the value back to the calling procedure
              return v;
         // function to be called to set the value of a specific paramater 'param'
         public void setParam(String param, String value)
              // looking up the whole Vector for the specific param if existing or not
              for (int i=0; i<PropertiesSet.size(); i++)
                   //the String i want to read the values in again
                   String s[][] = (String[][]) PropertiesSet.elementAt(i);
                   // comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
                   if (s[0][0].equals(param) == true)
                        //if the param-names are the same, we remove the param/value pair so we can add the new pair later in
                        PropertiesSet.removeElementAt(i);
                        // making sure the for loop ends
                        i = PropertiesSet.size();
              // if we land here, there is no such param in the Vector, either there was none form the beginng
              // or there was one but we took it out.
              // create a string array to place the param/value pair in
              String n[][] = new String[1][2];
              // add the param/value par
              n[0][0] = param;
              n[0][1] = value;
              // add the string array to the vector
              PropertiesSet.addElement(n);
         // function to save all data in the Vector to the properties file
         // must be done because properties might be changing while runtime
         // and changes are just hold in memory while runntime
         public void store()
              backup();
              String outtofile = "# file created/modified on "+createDate("-")+" "+createTime("-")+newline+newline;
              try
                   //opening stream to file for write operations
                   FileOutputStream PropertiesFileOuput = new FileOutputStream(PropertiesFile);
                   DataOutputStream PropertiesDataOutput = new DataOutputStream(PropertiesFileOuput);
                   // looping over all param/value pairs in the vector
                   for (int i=0; i<PropertiesSet.size(); i++)
                        //the String i want to read the values in
                        String s[][] = new String[1][2];
                        // trying to get out the array from the vector again
                        s = (String[][]) PropertiesSet.elementAt(i);
                        String param = "$"+s[0][0];
                        String value = s[0][1];
                        outtofile += param+" = "+value+newline;
                   outtofile += newline+"#end of file"+newline;
                   try
                        PropertiesDataOutput.writeBytes(outtofile);
                   catch (IOException e)
                        System.out.println("ERROR while writing to Properties File: "+e);
              catch (IOException e)
                   System.out.println("ERROR occured while writing to the property file for: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
         // sometimes before overwritting old value it's a good idea to backup old values
         public void backup()
              try
                   // reference to the original properties file
                   File OriginalFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
                   File BackupFile = new File(ObjectPropertiesDir+"/backup/"+ObjectPropertiesFileName+".backup");
                   //opening stream to original file for read operations
                   FileInputStream OriginalFileInput = new FileInputStream(OriginalFile);
                   DataInputStream OriginalFileDataInput = new DataInputStream(OriginalFileInput);
                   //opening stream to backup file for write operations
                   FileOutputStream BackupFileOutput = new FileOutputStream(BackupFile);
                   DataOutputStream BackupFileDataOutput = new DataOutputStream(BackupFileOutput);
              //     String content = "";
                   String line = "";
                   // do till end of file
                   while ((line = OriginalFileDataInput.readLine()) != null)
                        BackupFileDataOutput.writeBytes(line+newline);
              // error handlig
              catch (IOException e)
                   System.out.println("ERROR occured while back up for property file: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
                   System.out.println("this is a serious error - the server must be stopped");
         private String cutSpaces(String s)
              while (s.startsWith(" "))
                   s = s.substring(1, s.length());
              while (s.endsWith(" "))
                   s = s.substring(0, s.length()-1);
              return s;
         public String createDate(String seperator)
              Date datum = new Date();
              String currentdatum = new String();
              int year, month, date;
              year = datum.getYear()+1900;
              month = datum.getMonth()+1;
              date = datum.getDate();
              currentdatum = ""+year+seperator;
              if (month < 10)
                   currentdatum = currentdatum+"0"+month+seperator;
              else
                   currentdatum = currentdatum+month+seperator;
              if (date < 10)
                   currentdatum = currentdatum+"0"+date;
              else
                   currentdatum = currentdatum+date;
              return currentdatum;
         public String createTime(String seperator)
              Date time = new Date();
              String currenttime = new String();
              int hours, minutes, seconds;
              hours = time.getHours();
              minutes = time.getMinutes();
              seconds = time.getSeconds();
              if (hours < 10)
                   currenttime = currenttime+"0"+hours+seperator;
              else
                   currenttime = currenttime+hours+seperator;
              if (minutes < 10)
                   currenttime = currenttime+"0"+minutes+seperator;
              else
                   currenttime = currenttime+minutes+seperator;
              if (seconds < 10)
                   currenttime = currenttime+"0"+seconds;
              else
                   currenttime = currenttime+seconds;
              return currenttime;

  • Write the data into a file in 10 ms interval within 10 sec

    Hi,
    I'm trying to write the data into a file when I press a OK button and the data should write in a file every 10ms interval. After pressing the OK button the process will stop after 10 sec.
    I've attached my VI.
    Problem is that I'm getting the result every ms. How can I get the data every 10ms? So it'll come 1000 data within 10 sec.
    For other calculations purpose I'm using Amplitude and Level Measurements block to get the mean DC voltage, so when I change the Samples to Read and Rates, the process is getting stuck.
    Any kind of suggestion is appreciable.
    Thanks,
    Chotan
    Attachments:
    DAQ_Time_Checking_For10s_02.vi ‏131 KB

    See example attached, if needed
    Nghtcwrlr
    ********************Kudos are alwayzz Welcome !! ******************
    Attachments:
    Example.vi ‏36 KB

  • Write XML file on client

    I'm trying to generate XML files on a client machine. I'm using SQL*Plus Instant Client v 10.1.0.4.0 connected to DB version 10.1.0.3.0. I've created a view of XMLType and am able to select XML from this view. I've been unable to figure out a way to generate well-formed XML via a Spool command and Select statement as Sqlplus returns the XML as one row and has problems with line wrapping, embedded spaces, and also including the SQL command in the spooled output. I've tried many different permutations of Set commands to no avail.
    Is there a way to generate a valid XML file from Sqlplus on a client machine using the Spool command? If not Sqlplus, any other suggestions?
    Thanks,
    Glenn

    I would be inclined to write a pipelined function to take a clob, and break it up into pieces (perhaps after a '>').
    Here's an example of a pipelined function, which you can modify to suit your needs, such as working with CLOBs. You may also want to add more intelligence to it, such as checking for when the chunk is longer than 2000 characters.
    CREATE TYPE tvc2000 AS TABLE OF VARCHAR2(2000)
    CREATE OR REPLACE
    FUNCTION chopper
      p_string IN VARCHAR2
    RETURN tvc2000
    PIPELINED
    IS
      l_len NUMBER := LENGTH(p_string);
      l_out NUMBER := 0;
      l_pos NUMBER;
    BEGIN
      l_pos := INSTR(p_string, '>', l_out+1);
      WHILE l_pos > 0 LOOP
        PIPE ROW(SUBSTR(p_string, l_out+1, l_pos - l_out));
        l_out := l_pos;
        l_pos := INSTR(p_string, '>', l_out+1);
      END LOOP;
      IF l_out < l_len THEN
        PIPE ROW(SUBSTR(p_string, l_out+1, l_len - l_out));
      END IF;
      RETURN;
    END;
    SELECT *
    FROM TABLE(chopper('abc>def>'))
    COLUMN_VALUE
    abc>
    def>Tak

  • Write XML file in application server

    Experts,
    I'm using a transformation to generate a xml file:
      CALL TRANSFORMATION zdatafechomes
      SOURCE ficheiroexecucao = gt_source[]
      RESULT XML  xml_result.
    It's working fine. But i'm having problems in putting the "xml_result" (it's a type xtring) into the application server.
    Anyone knows how to do it ? Transaction cg3z it's different because the file comes from C:
    Best Regards,
    Mário.

    Hello Mario
    I do not see why the following logic should not work:
    *& Report  ZUS_SDN_XML_XSTRING_APPLSERVER
    REPORT  ZUS_SDN_XML_XSTRING_APPLSERVER.
    DATA:
      gd_dsn            type string,
      gd_xstring        type xstring,
      gt_kna1           type STANDARD TABLE OF kna1.
    start-of-selection.
      select * from kna1 into table gt_kna1 up to 10 rows.
      BREAK-POINT.
      call TRANSFORMATION id
        source itab = gt_kna1
        result xml = gd_xstring.
        gd_dsn = '/tmp/xml_as_xstring.file'.
        open DATASET gd_dsn for OUTPUT in BINARY MODE.
        check ( syst-subrc = 0 ).
        TRANSFER gd_xstring to gd_dsn.
        CLOSE DATASET gd_dsn.
    end-of-SELECTION.
    Regards
      Uwe

  • Exception while trying to write xml file

    When I try to write my DOM tree to an XML file a get the following exception form the transformer.transform() function call:
    Exception in thread "AWT-EventQueue-0" java.lang.AbstractMethodError: org.apache.crimson.tree.XmlDocument.getXmlStandalone()Z
    at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocumentInfo(DOM2TO.java:373)
    at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:127)
    at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:94)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:662)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:708)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
    at CentMon.ConfigRW.writeConfig(ConfigRW.java:77)
    The whole thing worked for 2 years. I did not change anything on the code. the only difference is that i have now office 2007 installed instead of office 2003.
    That's the code which generates the exception:
    import java.io.File;
    import java.io.IOException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.xml.sax.SAXException;
    public void writeConfig(Document doc){
    TransformerFactory tFactory =
    TransformerFactory.newInstance();
    Transformer transformer;
    if (doc==null){
    System.out.println("Document is null");
    else{
    try {
    transformer = tFactory.newTransformer();
    } catch (TransformerConfigurationException e) {
    transformer = null;
    System.out.println(e.getMessage());
    DOMSource source = new DOMSource(doc);
    StreamResult result = new StreamResult(new File(filename));
    try {
    if (transformer != null){
    transformer.transform(source, result);
    } catch (TransformerException ex) {
    Logger.getLogger(ConfigRW.class.getName()).log(Level.SEVERE, null, ex);
    }

    I am getting the exact same error when trying to write out an XML file. I have been following the J2EE Tutorial. Perhaps I need to look for a more recent tutorial.
    Exception in thread "AWT-EventQueue-0" java.lang.AbstractMethodError: org.apache.crimson.tree.XmlDocument.getXmlStandalone()Z
    at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocumentInfo(DOM2TO.java:373)
    at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:127)
    at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:94)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:662)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:708)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
    at com.wordhopper.xml.DOMXMLParser.writeXMLFile(DOMXMLParser.java:55)
    at com.wordhopper.gui.xmltool.XMLEditor.writeButtonActionPerformed(XMLEditor.java:217)
    at com.wordhopper.gui.xmltool.XMLEditor.access$100(XMLEditor.java:13)
    at com.wordhopper.gui.xmltool.XMLEditor$2.actionPerformed(XMLEditor.java:139)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6348)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6113)
    at java.awt.Container.processEvent(Container.java:2085)
    at java.awt.Component.dispatchEventImpl(Component.java:4714)
    at java.awt.Container.dispatchEventImpl(Container.java:2143)
    at java.awt.Component.dispatchEvent(Component.java:4544)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
    at java.awt.Container.dispatchEventImpl(Container.java:2129)
    at java.awt.Window.dispatchEventImpl(Window.java:2475)
    at java.awt.Component.dispatchEvent(Component.java:4544)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

  • [JS] Write XML file

    Hello 
    I read an XML file I y contribution of the change and I want to write it in a new XML file.
    I would get this presentation
    but I opt cesi
    Here is my code :
        leDossierOEBPS = "~/Desktop/content/";
        monEcritureContent(File (leDossierOEBPS + '/content.opf'),File (leDossierOEBPS + '/content5.opf'));
    function monEcritureContent(refFile,refFile2) {
       default xml namespace = 'http://www.idpf.org/2007/opf';
        var XMLHeader = '<\?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>';
        var XMLWorkbookHeader = "<\?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
        var XMLWorkbookHeader2 = " xmlns=\"http\://www.idpf.org/2007/opf\" unique-identifier=\"bookid\" version=\"2.0\"";
               if(refFile != null) {
                            refFile.open("r");
                            var XMLToParse = refFile.read();
                            refFile.close();
                            XMLToParse = XMLToParse.replace(XMLWorkbookHeader,"");
                            XMLToParse = XMLToParse.replace(XMLWorkbookHeader2,"");
                            var XMLData2 = new XML(XMLToParse);
                            XMLToParse = null;
                } else {
                        alert("Error opening XML file.");
    refFile2.open("w");
    refFile2.encoding = "UTF8";
    refFile2.writeln (XMLHeader+XMLData2.toXMLString());
    refFile2.close();
    What is the correct control to write the XML tree?
    Thank you

    I would like to used the class "namespace". 
    Currently I use it like this:
    default xml namespace = 'http://www.idpf.org/2007/opf';
    but I also have to put the two following
    unique - identifier = "bookid" version = "2.0".
    But my its too short deep.
    Thank you

  • How to write xml files

    I have a simple jsp page having name and id field, when user submits the page, it will create a xml file having datas of the user entered.and later if another user add his data, then it will update the xml file

    Extract the name, id whatever fields from the jsp page into a bean after submit. Then you can use DOM or SAX parser implementation to create a new xml file for the values you are now in your bean from jsp page.
    You can create the XML using DOM or SAX parsers. The implementation of those are almost easy. For better work you can also use JAXB if the application is complex or the XML format is complex and huge.
    -Sachin
    I have a simple jsp page having name and id field,
    when user submits the page, it will create a xml
    file having datas of the user entered.and later if
    another user add his data, then it will update the
    xml file

  • File Adapter write XML file with special characters

    Hi,
    I have a BPEL processes which use DB adapter to retrieve record and output in a XML document using File Adapter.
    In the table, some records contain these special characters - ">" , "<" , "." . I was expecting the file adapter will convert it to escape characters, but it didn't happen. it just put the same value back to the XML file, which cause other system to reject the file. Do anyone know how to resolve this ?
    The version of SOA is 10.1.3.4
    Thanks for the help.
    Calvin
    Edited by: user12018221 on May 25, 2011 1:48 PM

    one option is to specify validateXML on the partnerlink (that describes the file adapter endpoint) such as shown here
    <partnerLinkBinding name="StarLoanService">
    <property name="wsdlLocation"> http://<hostname>:9700/orabpel/default/StarLoan/StarLoan?wsdl</property>
    <property name="validateXML">true</property>
    </partnerLinkBinding>
    hth clemens

  • How to read and write Xml file at client side using JavaScript !

    Hello,
    i am new to javascript.
    I have requirement to read and update XML file at client side.
    Will you please guide what could be the best way to read and update XMl file using javascript.
    Thanks,
    Zuned

    This is a Java forum,not a Javascript forum. Maybe you should ask here [http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s|http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s].

  • Read and Write XML files

    I work on a Flex application that will be used to record time entries for manufacturing plan. I have two problems to solve:
    1- Can I read an XML file from a local drive? (C: /temp/file)
    2- If the system where I call the web service is offline, I must create local file that are going to be read later vwhen the system will be up again. How can I create local file from Flex?

    A web-based app cannot access the local drive w/o user permission.
    Sometimes, folks upload local files to a server (also requiring user
    permission) and then request the file from the server.
    You can use local SharedObject to store data, although there are limits to
    how much data.
    The recommended option is to create an AIR app.  It will be able to access
    the local drive once it is installed.

  • Can I select when do i want to write my data into a file?

    What I want is like,
    When I click a button as ON then only it goes an writes the data into a spreadsheet.
    Now i have made the bolllean so that it will show TRUE when you have to write...but if FALSE nothing should happen...
    and I cant see any option in Write to Spread Sheet function for it..
    So can you help me out with what should I do
    Solved!
    Go to Solution.

    You put the Write to Spreadsheet file in a case structure.
    I would recommend looking at the online LabVIEW tutorials
    LabVIEW Introduction Course - Three Hours
    LabVIEW Introduction Course - Six Hours

  • Write blob value into a file

    Hi, all
    I'm looking for the correct method of writing an internal blob value into a file. I know that the best way is using some external language. I.e. Java or C. But also I met a number of solutions of doing within pl/SQL block. All of them look like this:
    CREATE OR REPLACE PROCEDURE Write_Binary_file
       PC$Directory IN VARCHAR2
      ,PC$File_Name IN VARCHAR2
      ,PC$SQL_Order IN VARCHAR2
      ,PB$Raise     IN BOOLEAN DEFAULT FALSE
    -- Procedure to dump a BLOB column onto a file
    -- parameters:
    -- PC$Directory : name of an existing Oracle Directory
    -- PC$File_Name : name of the expected output file
    -- PC$SQL_Order : SQL order to select the BLOB column
    -- PB$Raise     : boolean to indicate if the process
    --                would be stopped after an error
    IS
      src_lob    BLOB;
      buffer     RAW(16384);
      amt        BINARY_INTEGER := 16384;
      pos        INTEGER := 1;
      LF$FicOUT  UTL_FILE.FILE_TYPE ;
      LC$Msg     VARCHAR2(2000) ;
    BEGIN
    -- get the BLOB column --
    BEGIN
      EXECUTE IMMEDIATE PC$SQL_Order INTO src_lob ;
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        LC$Msg := 'Write_Binary_File(): NO_DATA_FOUND' ;
        IF PB$Raise THEN
          RAISE_APPLICATION_ERROR( -20100, LC$Msg ) ;
        END IF ;
        Dbms_Output.Put_Line(LC$Msg) ;
      RETURN ;
    END ;
    -- open the output file --
    LF$FicOUT := UTL_FILE.FOPEN( PC$Directory, PC$File_Name, 'W', 32764 ) ;
    -- write the file --
    LOOP
      -- read the chunks --
      Dbms_Lob.READ (src_lob, amt, pos, buffer);
      -- write the chunks --
      Utl_File.Put_Raw(LF$FicOut, buffer);
      pos := pos + amt;
    END LOOP;
    -- close the file --
    Utl_File.Fclose(LF$FicOut);
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        utl_file.fclose(LF$FicOut);
      WHEN OTHERS THEN
        LC$Msg := 'Write_Binary_File() Error : ' || TO_CHAR( SQLCODE ) || ' while managing file ('
    || PC$Directory || ') ' || PC$File_Name ;
        IF PB$Raise THEN
          RAISE_APPLICATION_ERROR( -20100, LC$Msg ) ;
        END IF ;
        Dbms_Output.Put_Line(LC$Msg);
    END Write_Binary_file;
    But this code seems not working. The problem is it always creates a file with a bit bigger size than initial one. So jpg copy will be never be opened with any viewer.
    Can anybody explain this issue and give any workaround?
    Thanks

    You need a code block like this:
    DECLARE
       l_file       UTL_FILE.FILE_TYPE;
       l_buffer     RAW (32767);
       l_amount     BINARY_INTEGER     := 32767;
       l_pos        INTEGER            := 1;
       l_blob       BLOB;
       l_blob_len   INTEGER;
    BEGIN
    -- Open the destination file. Note the third parameter "wb"
       l_file := UTL_FILE.FOPEN ('TEST_DIR', 'extract3.jpg', 'wb');
    -- Get LOB locator
    FOR rec IN (
    SELECT blob_col  l_blob
          FROM test_my_blob
       --AND ROWNUM =1
    LOOP
       l_blob_len := DBMS_LOB.getlength (rec.l_blob);
    -- Read chunks of the BLOB and write them to the file
    -- until complete.
       WHILE l_pos < l_blob_len
       LOOP
          DBMS_LOB.READ (rec.l_blob, l_amount, l_pos, l_buffer);
          UTL_FILE.put_raw (l_file, l_buffer, FALSE);
          l_pos := l_pos + l_amount;
       END LOOP;
      commit;
    END LOOP;
    -- Close the file.
       UTL_FILE.FCLOSE (l_file);
    EXCEPTION
       WHEN OTHERS
       THEN
    -- Close the file if something goes wrong.
          IF UTL_FILE.IS_OPEN (l_file)
          THEN
             UTL_FILE.FCLOSE (l_file);
          END IF;
          RAISE;
    END;

Maybe you are looking for