Writting file in xml format

Hello guys,
I am just wondering if i can write to a text file in xml format:
For example if i want to save the following:
Avisha 00/06/2000
The text file should show:
<record>
<name>Avisha</name>
<DOB00/06/200</DOB>
</record>
I think i probably needs to use some sort of XML schema, i never done it before and i would appriciate your help.
Thanks,

corlettk wrote:
thomas.behr wrote:
Well, for simple cases, such as your example, just create an appropriate String and write that to your file.
For more complex cases, create a org.w3c.dom.Document (using DocumentBuilder and DocumentBuilderFactory), create the appropriate structure and use a javax.xml.transform.Transformer (created via TransformerFactory) to convert your Document from a DOMSource to StreamResult.I'm not a fan of the DOM solution... It's slow and very memory hungry... Goog for small datasets.
@OP If you can, I recommend using an XMLBinder (like [XML-Beans|http://xmlbeans.apache.org/] jusr for example) to both read and write all your XML.Errr, XMLBeans and the like will still be using DOM under the covers, so the memory issue is still as relevant as before. Happily, this turns out to be "not as much as you probably think" anyway. So the decision is a design one. Do you have schemas for this XML? You don't? Ah well, a binding framework's out of the question anyway. What are you doing with it? ("Processing it" isn't an answer). Where is it coming from? ("my codez" isn't an answer). What format need it be in? ("XML format" isn't an answer)
Building a DOM tree and serializing it isn't necessarily all that stupid an idea

Similar Messages

  • Convert the flat file to xml format.

    hi,
    I need to write a interface program in the R/3  to pull the flat file data from the unix application server and do some manipulation and place back into the unix application server in XML format, From the unix box XML file taken by the XI server.
    pls give me some idea to convert the flat file to XML format, through any function module or any other logic is there...
    with regards,
    Thambee.

    Hi Thambe
    in addition to the above posts
    Program to convert flat file to XML file.
    please download tool from this link:
    http://www.download.com/Stylus-Studio-2008-XML-Enterprise-Suite/3000-7241_4-10399885.html?part=dl-StylusStu&subj=dl&tag=button&cdlpid=10399885
    how to use:
    http://www.stylusstudio.com/learn_convert_to_xml.html
    http://www.sap-img.com/abap/sample-xml-source-code-for-sap.htm
    Flat file to XML
    CONVERTION OF FLAT FILE TO XML : NO OUT PUT FOUND
    Converting Idoc flat file representation to XML
    how to convert flat file into IDOC-XML
    Thanks
    sandeep sharma
    PS ; if helpful kindly reward points

  • Log file in xml format: bad idea?

    Hey
    Im trying to write a class that will let other classes keep a log on whatever they want to. Whoever wants to write a message to a log file will call a function there, with the specified log name and the message, and my class will write it in xml format into the file.
    Simple right? But here's the catch: in order to append a log into the file, I have to read it all first, then create the Element and add it to the root element. That meens that as the file grows, so will the time it takes to read it, and eventually log will take loads of time...
    All this would not have happen otherwise, with simple text files, as all I have to do is to open the file for appending, which wouldn't take that much time.
    So my questions are: Am I stupid to think this is possible with xml? Should I open the xml file as text file and then manipulate it? Are there any other possibilities?
    Thanks for your help - Uzi

    Writing logs in an xml file is a very good idea and will later on provide you with a lot of flexibility to perform queries and how u want to display it.
    Simple right? But here's the catch: in order to append
    a log into the file, I have to read it all first, then
    create the Element and add it to the root element.
    That meens that as the file grows, so will the time it
    takes to read it, and eventually log will take loads
    of time...Why do you want to read the whole file for writing new elements. You dont have to do that. I have a simple idea for your problem.
    e.g <logfile>
    <log>
    </log>
    </logfile>
    So now u want to add another log element. Use RandomAccessFile's length() method to find the size of the file.
    Find the size of </logfile> e.g if it is sizeOfString.
    Use RandonAccessFile's seek() method as follows
    .......seek(lengthOfFile - sizeOfString);
    This will move the pointer of the RandomAccessFile to this position. Next step is you can use writeBytes method to further write to this file.
    That will increase the speed and performance and would give u great end results of an xml file.

  • How to store xml data into file in xml format through java program?

    HI Friends,
    Please let me know
    How to store xml data into file in xml format through java program?
    thanks......
    can discuss further at messenger.....
    Avanish Kumar Singh
    Software Engineer,
    Samsung India Development Center,
    Bangalore--560001.
    [email protected]

    Hi i need to write the data from an XML file to a Microsoft SQL SErver database!
    i got a piece of code from the net which allows me to parse th file:
    import java.io.IOException;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import org.apache.xerces.parsers.SAXParser;
    import java.lang.*;
    public class MySaxParser extends DefaultHandler
    private static int INDENT = 4;
    private static String attList = "";
    public static void main(String[] argv)
    if (argv.length != 1)
    System.out.println("Usage: java MySaxParser [URI]");
    System.exit(0);
    String uri = argv[0];
    try
    XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    MySaxParser MySaxParserInstance = new MySaxParser();
    parser.setContentHandler(MySaxParserInstance);
    parser.parse(uri);
    catch(IOException ioe)
    ioe.printStackTrace();
    catch(SAXException saxe)
    saxe.printStackTrace();
    private int idx = 0;
    public void characters(char[] ch, int start, int length)
    throws SAXException
    String s = new String(ch, start, length);
    if (ch[0] == '\n')
    return;
    System.out.println(getIndent() + " Value: " + s);
    public void endDocument() throws SAXException
    idx -= INDENT;
    public void endElement(String uri, String localName, String qName) throws SAXException
    if (!attList.equals(""))
    System.out.println(getIndent() + " Attributes: " + attList);
    attList = "";
    System.out.println(getIndent() + "end document");
    idx -= INDENT;
    public void startDocument() throws SAXException
    idx += INDENT;
    public void startElement(String uri,
    String localName,
    String qName,
    Attributes attributes) throws SAXException
    idx += INDENT;
    System.out.println('\n' + getIndent() + "start element: " + localName);
    if (localName.compareTo("Machine") == 0)
    System.out.println("YES");
    if (attributes.getLength() > 0)
    idx += INDENT;
    for (int i = 0; i < attributes.getLength(); i++)
    attList = attList + attributes.getLocalName(i) + " = " + attributes.getValue(i);
    if (i < (attributes.getLength() - 1))
    attList = attList + ", ";
    idx-= INDENT;
    private String getIndent()
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < idx; i++)
    sb.append(" ");
    return sb.toString();
    }// END PRGM
    Now , am not a very good Java DEv. and i need to find a soln. to this prob within 1 week.
    The next step is to write the data to the DB.
    Am sending an example of my file:
    <Start>
    <Machine>
    <Hostname> IPCServer </Hostname>
    <HostID> 80c04499 </HostID>
    <MachineType> sun4u [ID 466748 kern.info] Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 360MHz) </MachineType>
    <CPU> UltraSPARC-IIi at 360 MHz </CPU>
    <Memory> RAM : 512 MB </Memory>
    <HostAdapter>
    <HA> kern.info] </HA>
    </HostAdapter>
    <Harddisks>
    <HD>
    <HD1> c0t0d0 ctrl kern.info] target 0 lun 0 </HD1>
    <HD2> ST38420A 8.2 GB </HD2>
    </HD>
    </Harddisks>
    <GraphicCard> m64B : PCI PGX 8-bit +Accel. </GraphicCard>
    <NetworkType> hme0 : Fast-Ethernet </NetworkType>
    <EthernetAddress> 09:00:30:C1:34:90 </EthernetAddress>
    <IPAddress> 149.51.23.140 </IPAddress>
    </Machine>
    </Start>
    Note that i can have more than 1 machines (meaning that i have to loop thru the file to be able to write to the DB)
    Cal u tellme what to do!
    Even better- do u have a piece of code that will help me understand and implement the database writing portion?
    I badly need help here.
    THANX

  • DME file in XML format in SAP 4.6C

    Hi Experts,
    For a Belgium client, I have a requirement to generate DME file in XML format for payments made to foreign and domestic vendors.  I want to know the following,
    1.  Can DME file be generated in XML format using classic payment medium programs RFFOBE_E and RFFOBE_I.
    2.  If not why and what are the other options.
    3.  I also came to know that there is an options of using Payment medium workbench - through XML format trees BE_BEPDTA and BE_PIBDTA.  But since we are in 4.6C, i am not able to create a payment format.  Is there any support package or patch that is required.
    4.  I tried for SEPA_CT - again a XML format tree but was not very successful as that too was not available in SAP 4.6C.  Is there any way that I can get this done in 4.6C - any support packages or patches available?
    Thanks

    Hi Kaylan,
    could you please share that documentation with me too.
    Thanks, Regards,
    Alex Cardona

  • Convert gzip files into XML format

    We have a requirement where we receive gzip files. These files are zipped file containing base64 binary format csv files. We would have to convert these files into XML format. Please let me know any of the following.
    1. Is there any Xpath query or XSL function (somthing similar like doTranslateFromNative() ) to convert from gzip files to XML format.
    2. If we need to unzip the zipfile outside fusion, then java code piece to unzip the gzip file. I guess after that we can use the usual doTranslateFromNative() function to translate to XML format, since after unzipping the gzip file, they are base64 binary formats.
    Thanks in advance,
    Toms

    There is an option to do pre-processing and post processing of Files when using File adapter. You need to create a valve which will first do pre processing and send the output to FileAdapter.
    You can get more information here:
    http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_file.htm#CACDHGGG
    under section: 4.2.14 Pre-Processing and Post-Processing of Files
    Essentially you will use Java to unzip the file first and then the unzipped content will be passed to the adapter.

  • STORING DATA IN FILE IN XML FORMAT THROUGH JAVA ?

    HOW TO STORE DATA IN FILE IN XML FORMAT THROUGH JAVA PROGRAM?

    Have you looked into JAXB?
    That is a new way of processing XML into Java classes or visa versa.
    Otherwise, there are a lot of other XML related tools for Java in the -XML link on the left side of the page.

  • Cannot Write Files to my Formatted External Hard-drive

    I've been struggling with this problem for awhile now. I have a 200GB external hard drive that I used on my windows box. I have music on it and would like to use it on my macbook. When I plug it into my macbook, it mounts and shows up on the desktop. I can go into it in finder, and view the files and folders that are on it. I can also create new folders. However, when I try to read or write files to/from the hard drive, finder stalls at 'zero KB of x MB written'. If I try to copy a file to the drive, the file will be created but it will be of zero or very very small size.
    I reformatted the drive with Disk Utility and also via the command line with 'diskutil reformat /dev/disk1s5' and these reformat the drive successfully, but the same problems occur.
    What could be going on? The drive is not faulty, and it mounts just fine. I just can't read or write from the drive in OS X.
    Please help! Thank you in advance.

    The NTFS file format is not really that compatible with macs (you can only "read" files, but not "write" to them). Also, while you can reformat a hard drive with the same or different file type, the NTFS type is the only one that will not let you go from having a NTFS formatted drive and reformatting it as a different format (you can do it again as NTFS but that's it). If you have a FAT or FAT32 formatted drive, you can go and reformat it as NTFS, but once it has had the newer windows format style done to it, you can't change it to anything else.
    Also, as I think you said you could read from it at first, and then were not able to?, this would be because the reading of the files would have been fine, but as soon as you went and reformatted it again (which basically wipes the slate clean), you lost all the data that possibly was on there, and now as an NTFS format with no data, therefore nothing for a Mac to get a chance to "read", you have nothing and can only use this as an NTFS drive for windows (or any other possible OS that is NTFS compatible).
    Sorry about the bad news... Try to sell it to a windows person and get another external hard drive (formatted as FAT32 or not pre-formatted yet, then format as FAT32) so that you can use that with your Mac...

  • Why does photoshop elements 10 back up files in xml format

    I am trying to backup my catalog including tags to my external hard drive. When I do the files are all in XML format. When I attempt to open using Photoshop
    i get "wrong type of file" or they are just a lot of code. What is going on. Where are the pictures?

    I downloaded them into the same folder, and once that was done, I did as you said and opened PhotoshopElements_10_LS15.exe. It asked for my serial number and everything, seemed as though it was installing, and asked to restart in order to complete the process. I restarted the computer, and...I don't see Adobe Photoshop Elements 10 anywhere. There is a folder on my desktop that goes by the name of Photoshop Elements 10, but it only contains data files and things that I can't use. It's not the actual software....
    What should I do?

  • Error Log entry Unable to write file with XML Saver

    Hi all,
    I have just encountered the following problem. I am saving a XML file using the XML Saver. Another BLT reads the file, changes something, and saves it again with the same name.
    The file is saved, but the NetWeaver SAP Log gives the error
    "Unable to write file /usr/sap/<SID>/JC00/j2ee/cluster/server0/apps/sap.com/xappsxmiiear/servlet_jsp/XMII/root/CM/<folder>/file.xml"
    Is it a problem with the new storage mechanism in MII 12? Even if I delete the file first and then save it again with the same name, the error is displayed (though the file is saved).
    Michael

    Hi Mike,
    no, the Debug only says "Begin Action XML Saver" and "End Action XML Saver".
    The action however writes the file, the contents has changed after the BLT has run.
    Well, I have just tried the Text Saver with the same file (name and contents). It also gives the error. I now wanted to delete the folder. The folder disappered from the workbench view, and the Netweaver log says "Unable to process service message".
    I then clicked "publish" on the parent folder and tried to create the folder again, but although the folder was not displayed, the workbench said "the folder already exists". When I start my BLT, it could write the file into the folder which then reappeared in the workbench.
    Hm, maybe our installation has some problems? Feels like missing authorizations...
    Michael

  • How to convert CSV/Text files to XML format

    Hi,
    I am trying to convert a .csv/.txt(Flat) file(s) to XML format. How can i achive this?
    Ex: I want to convert this text file to XML.
    Book#      first name                                last name                               ID#                 ID1#      F#
    B99          FRISBY                                  NASIER                                  LUCJ A         A 3127      1    
    B131         HAWKINS                              MICHAEL                               LUCJ A         A 3129       2    
    B313         KING                                     JOSHUA                                 CUCJ I         I-DORM      10   
    B307         GRAVES                               KIMBERLY                              NUCJ F         F-DORM     24-FL
    R469         HEATH                                  DARRELL                                SUCJ A         A 3132       1    
    R212         PEREZ                                  DARRELL                                SUCJ A         A 3133       2    
    R62          COFFEY                                GREGORY                               NUCJ HC      H C 3112    3FLOOR
    R215         BLACKWELL                          DEREK                                   LUCJ OOW     W 01       1     Could anyone please suggest me if we have any open source java api to acheive this?
    Thanks,
    Srikanth.

    Have a look at [http://servingxml.sourceforge.net/|http://servingxml.sourceforge.net/] or [http://www.talend.com/|http://www.talend.com/]

  • Error attempting to write file in .png format

    Hello All,
    I am stuck on a problem that I can not find a solution to.  We receive customer prints saved as a PDF and then save them as a PNG file to import them in to Excel.
    Up until this morning this has never been a problem.  On the Windows 7 machine we use to do this we are now receiving an error message, see below.
    We can save the original PDF as any other file type except as a PNG on this machine.
    We have tried the same processes used on 2 other machines (identical machines, software versions and network locations) and it works just fine, no errors.
    All 3 machines are Windows 7 Professional 64 bit running Adobe Acrobat XI Version 11.0.09
    Thank you and Any help is appreciated!!!!!
    Andy

    I'm having the same problem,
    Acrobat XI  11.0.10
    Definitely lots of space free, checked rebooted PC, its a new install, tried local drive to make sure not permissions, etc...
    I'm a s/w developer, and I'm sure its not a PC issue, but an acrobat issue.
    Can we please get an update on a fix for this?
    Thanks in advance
    Aaron.

  • Ack file date and time format is same as in source xml format

    Hi...All,
    1) my scenario is file-rfc-file using BPM,
    we are getting file in xml format from source along with timestamp and this data will be going to R/3 and the acknowledgement (success or failure) file will be sending back to source system.
    in this sceneario we have to fulfill in the follwing client requirement
    File1.<same File1 date and time>.XML
    Is it possible to make it as the following? if it is possible
    could u please let me know how to fulfill the follwing requirement.
    ACK File1.<same File1 date and time>.XML
    Where <same File1 date and time> format = u2018YYYYMMDDhhmmssu2019 .
    2) Is the XML file name visible in the SAP-XI monitoring screen and will it help to trace the messages?
    thanks in advance,
    Pasi.

    Hi,
    I didnot under stand your first question coulf you be more specfic.
    2. Ans : In general , we will follow the below steps
    --First we we check for the file is picked or no, if not see the Sender side CC parameters like mode and path details
    --If file was picked then we need to check whether we are using the File content conversion parameters or not if yes we need to check the FCC parameters ,
    Goto RWB-Channelmonitoring by the following link
    http://host:port/mdt/channelmonitorservlet
    select the sender side CC name and check for errors
    If no errors in above, goto SXMB_MONI for Integration Engine xml processing , check for successful or error occured black or red color
    --if success in SXMB_MONI then we need to check in RWB as above channel monitor now select the receiver side CC
    If no errors then check for output file is placed intarget or not
    Please reward points if it helps
    Thanks
    Vikranth

  • How to SaveAs the MSword file into xml file format using Java APIS?

    Hello all,
    I want to convert MSword file into Xml format using java APIS or any other inbuilt APIS that i can integrate in Java code.

    Sorry, that doesn't make much sense.
    The XML you gave is a configuration file for txt2xml utility. It doesn't represent the output format.
    Are you a user of this utility?

  • How to automate conversion of PDF forms to XML format

    Hi
    I have created a form using adobe livecycle designer 8. It has a email submit button that will send the form as a pdf file to a server.
    Once the server recevive this pdf file, they will store the pdf file into a local drive. How do I convert the pdf files in the local drive into XML format without actually opening the pdf file in the Adobe Professional and clicking export data as XML?
    Is there a way to write a code to convert these pdf files to XML format automatically?
    Hope someone can help me with this issue
    Regards
    Delvin Khong

    Hi Andersson,
    The request command is a form server command? Where do i type the Request.Form("page.form.field"). I dont really understand your statement on "Use request on the receiving page to get data" Could you help me by explaining more?
    Thank a lot for your advice
    Warmest Regards
    Delvin Khong

Maybe you are looking for