What the best way to create XML files from JAVA application?

Hi to all,
I need to edit and to create new filex in format of xml. I know to parse, but what would be the best way to do:
1. - Create new file, create like simle text file, or there is some clases that know to do it in more simple way
2.a - Edit XML file, to take some data and add it to the XML in the place I want to.
2.b - Also Edit, but not to add fields, just update some of them.
Code examples or links to samples woul be welcomed.
Best regards, Nick.

I have tried working with XML directly using the Java classes but this was a pain. I then looked at DOM4J and JDOM and found JDOM easier to use.

Similar Messages

  • Best way to create SVG file from drawing application?

    I am developing a drawing application that allow the users to draw and edit static two dimensional images such as Rectangles, Ellipses and Text. I have a superclass SVGShape that contains all the common features of a shape such as x1, x2, color etc. I then have SVGRectangle as a subclass of SVGShape.
    I want to know what would be the best way to create an SVG file from this? An idea I have at the minute is to have an abstract method getSVG() in the SVGShape class, and then implement the method in the subclasses. I will then create a new class called SVGManager which iterates through the list of shapes (Btw I'm using MVC, my shapes are stored in a Collection) and uses the getSVG() mehtod in each shape to build up a SVG file.
    What do you think of this? Any better ideas?
    Thanks guys

    I used a visitor for this in a similar project, so that when the svg library is used in a applet or browser and the writing functionality isn't required, it may be omitted from the bundle.
    Pete

  • What's the best way to create XML file with a schema from a database table?

    Hi,
    I want to create an XML file from a database table (which has over 600 columns) using XML schema (.xsd file). I want to know the best way to do this.
    The output XML file is NOT a direct data dump from the DB table, there�re some logic around it, such as the XML file has some hierarchy with repeating tags.
    I have done this using JAXB by creating Java classes form XML schema, but I don�t want to map 600 DB columns to these Java classes manually, and loop through the record set to create repeating tags.
    I know there are few tools around now like MapForce (Altova), how do people do these now?
    Thanks,
    Chandi

    Can you use a schema when we compose XML doc from Database tables?
    Actually, I'm using SQL Server (sorry, wrong forum). But, I thought a Java tool would have a solution for me.

  • What is the best way to create Aperture book from Pages '09 document?

    What is the best way to create Aperture book from Pages '09 document?

    There is no way to import pages documents to Aperture and convert them to an Aperture book. Aperture books can only be created by manually adding images and text to the pages of a book, and using the layout of the predefined templates.
    The best you could do, would be to print your pages document to pdf and import the resulting pdf file into Aperture as a new project. This will create one image for each page. Then select the page images all at once and  create a new book. Select a theme with fullsize page images, like "picture Book", and then add the images of the pages to the empty pages of the book.
    But probably would you get a much better quality and layout, when you recreate your pages document in Aperture, by starting with an empty book and copying and pasting the text from your Pages document. But don't paste the photos from the document - try to use the originals of those photos.

  • Whats the best way to create USER variable in BI Apps?

    I have just installled BI Apps and am trying to integrate EBS R12 with OBIEE 11g
    We have USER variable already defined in the BI Apps rpd.
    In EBS Security context init block i need to define USER variable, but when i define it... it says *'USER' has already been defined in the variable "Authentication"."USER"*
    Whats the best way to create USER variable for EBS Security Context init block?
    1) Delete the existing USER variable and then define a new one ( in this case all the places where USER variable is getting used in the rpd would become <missing>)
    And i was told that it should not be done.
    Let me know how can it be done.
    Thanks
    Ashish

    Disable existing Init block and then double click on USER variable and hit on NEW... button to create new Init block
    Thanks
    Edited by: Srini VEERAVALLI on May 1, 2013 4:18 PM

  • What's the best way to create a panorama from a series of images?

    What's the best way to create a panorama from a series of images?

    This is PhotoMerge result
    This is WLPG
    This is a manual merge
    Before anyone comments on the poor image quality, I know. Its not my photography.
    The beach huts were in an arc which doesn't help.
    You can see that the photomerged image has not 'understood' the image and has bad destortion on the doors of some huts. The blend lines are also visible

  • Creating XML file from Java Bean

    Hi
    Are there any standard methods in Java 1.5 to create XML file from java bean,
    i can use JAXB or castor to do so,
    But i would like to know if there is any thing in java core classes,
    I have seen XMLEncoder, but this is not what i want.
    Any ideas
    Ashish

    Marshall JavaBean to an XML document with JAXB or XMLBeans.

  • Oracle 10.1, Whats the best way to load XML in database?

    Hi All,
    I am a typical Oracle developer. I know some Java and some XML technologies, but not an expert.
    I will be receiving XML files from some system, which will be,
    - of reasonable size like 2 to 15 MBs
    - of reasonable complexity, like the root element have children, grand-children and great-grand-children, with attributes and all
    - Every day it needs to be loaded to Oracle database, in relational format
    - we need not update the XML data, only put the XML data in relational table
    My questions are,
    - With Oracle 10.1, XML DB, what is the best way to load this XML file to relational Oracle tables ?
    - What can be the steps in this process ?
    - In the documentation, I was lost and was not able to decide anything concrete
    - If I write a pure Java program with SAX API and load the data to Oracle database in same program, is it a good idea?
    - Is there any pure Oracle based way to do this?
    - If I want to avoid using DOM parser, as it will need more JAVA_POOL_SIZE, what can be the way ?
    Please help.
    Thanks

    Many customer solve this problem by registering an XML Schema that corresponds to their XML and then creating relational views over the XML that allow them to access the content in a relational manner. They then use insert as select operations on the relational views to transfer data from the XML into relational tables where necessary. There are a large number of threads in this forum with detailed examples of how this can be done. Most of the customers who have adopted this approach have discovered that this is the least complex approach in terms of code that to be developed / maintained and offeres acceptable performance.

  • What's the best way to transfer mp3 files from a thumb drive to an iphone?

    I have an iphone 5s. I also have multiple mp3's on a thumb drive. What's the best way to get them onto the iphone so that I can listen to them? I don't have a mac. PC only.

    Can itunes be used on a PC?
    Yes.  You are currently in the "iTunes for Windows" Forum.  85% of all iTunes installations on computers are running on Windows.

  • The nicest way to generate xml-files by Java???

    I have to generate huge and quite complex xml files by Java. I have to fetch the data from a Oracle database. What I really don't know is a proper and reliable way to this? I could of course create a String and concatenate all the tags, attributes and data but it doesn't feel right. I guess this is a quite common task and there are many established ways to this by Java. My question is what is the best way to this? What is your suggestion?
    Thank you for any clues...

    Hi,
    Since you have access to the database, I think one of the best way is to create stored procedures that will generate those files for you (using SQL/XML functions preferably) and return the content to the Java caller.

  • Create XML file from java

    Hi all i am working to create a XML file using java can any one show me some sample code how to do so

    All I suggested was to insert a single line ("X.serialize(root);") into your code. Anyway, here's a ready-to-compile source code based on yours. This code utilizes the Xerces-J class library.import java.io.File;
    import java.io.FileWriter;
    import org.apache.xerces.dom.DocumentImpl;
    import org.apache.xml.serialize.OutputFormat;
    import org.apache.xml.serialize.XMLSerializer;
    import org.w3c.dom.Element;
    public class Test {
      public static void main(String[] arguments) {
        FileWriter out;
        DocumentImpl d;
        Element root;
        XMLSerializer X;
        try {
          System.out.println(" creatin ");
          File fos = new File("xsr.xml");
          out = new FileWriter("xsr.xml");
          System.out.println("created File .." + fos.getName());
          out.flush();
          d = new DocumentImpl();
          System.out.println("create root");
          root = d.createElement("abc");
          System.out.println("creating element");
          d.insertBefore(root, null);
          //out.write(d.createAttribute(""));
          OutputFormat o = new OutputFormat(d);
          System.out.println("Output format...");
          o.setIndent(5);
          o.setIndenting(true);
          o.setDoctype("lab1.dtd", "lab1.dtd");
          o.setDoctype("name of dtd file", "name of dtd file");
          X = new XMLSerializer(o);
          X.setOutputCharStream(out);
          X.serialize(root);
          out.flush();
          out.close();
        catch (Exception e1){
          e1.printStackTrace();
    }

  • What is the best way to include external files in an application?

    I am developing a vocabulary-training program (Adobe AIR using Flex Builder 3). Asks you what an equivalent of a czech word is in english and the other way. I am storing the "dictionaries" in external XML files. I would like to include about twenty of them in the installation. So far I just had them in the applicationDirectory, but now, I added an editing feature and I ran across the fact, that I cannot write into the applicationDirectory. So I figured the most intuitive place for the dictionaries would be in the documentsDirectory/name of program. However, how do I tell the AIR installation to make the according folder and include the files?
    How do I do this, or what do you think is a better solution? Thanks!

    If this post answers your question or helps, please mark it as such.
    I'm creating an application that stores data in the "applicationStorageDirectory".      
    Mac storage directory is <appData>/<appId>/Local Store/
      where <appData> is user preferences folder, typically /Users/<user>/Library/Preferences
    Win: storage directory is <appData>\<appId>\Local Store\
      where <appData> is typically C:\Documents and Settings\<userName>\Application Data
      Note: Vista uses "junctions", which behave like shortcuts but look just like regular folders.
        It is not possible to access them, and any attempt to do so will give you an "Access Denied" error.
        Here is the real folder location:
          C:\Users\<userName>\AppData\Roaming\ContactManager\Local Store\contacts.xml
    Linux: <appData>/<appID>/Local Store/    where  <appData>  is  /home/<user>/.appdata
    Here is how to code to read from and write to a file there in an AIR app:
    var contactsFile:File;
    var contactsXML:XML;
    var contactsXLC:XMLListCollection;
    var stream:FileStream;
    contactsFile = File.applicationStorageDirectory;
    contactsFile = contactsFile.resolvePath("contacts.xml");
    stream = new FileStream();
    if (contactsFile.exists) {
        stream.open(contactsFile, FileMode.READ);
        contactsXML = XML(stream.readUTFBytes(stream.bytesAvailable));
        stream.close();
        contactsXLC = new XMLListCollection(contactsXML..contact);
    }else{
        var outputString:String = '<?xml version="1.0" encoding="utf-8"?>\n<contacts>\n';
        for each(var xml:XML in  contactsXLC){
          outputString += xml.toXMLString();       
          outputString += "\n";
        outputString += "</contacts>\n";
        outputString = outputString.replace(/\n/g, File.lineEnding);
        stream = new FileStream();
        stream.open(contactsFile, FileMode.WRITE);
        stream.writeUTFBytes(outputString);
        stream.close();

  • What the best way to create User defined table with ADDON purpose

    Hi folks, how are you ?
    I´m beginner in development to business one, and I m studying to develop ISV addons.
    But, during my exercises and analisys, I learned that have two ways to create tables and fields in business one. One way is throght by wizard in business one using Tools Menu > Configuration Tools > User Defined Tables >
    Obs: I ´m using Business One Patch Level 9.
    Other way, is create the tables and fields using DI API
    But, my question is. When I develop one addon, or one UDO form that uses one set of user defined tables or used defined fields that where created by the first way (by wizard in B1), how I deploy this in other business one installation ? The package process will ensure the creation of this tables in another enviroment or I must implement the creation of user defined tables using DI API so that this code is called during the installation?
    If in cases of addon develop I must use DI API to create user defined tables, How can I use my classes with this responsibility in package process ?
    Thanks my friends.

    Hi Renan,
    You just need to put your logic in to the startup of your application, after you've established your connection to the UI API and DI API. All this will be triggered in the constructor of your main class.
    namespace MyNamespace
    public class MyAddon
      bool runAddon = true;
      bool initialised = false;
      const string ADDON_NAME = "My Addon";
      public static void Main()
            MyAddon addOn = new MyAddon();
            if(runAddon)
                  System.Windows.Forms.Application.Run();
            else
             Application.Exit();
      public MyAddon()
            // Connect to SBO session for UI
            if(!SetApplication()) runAddon = false;
      private bool SetApplication()
            // Code goes in here to establish UI API and DI API connections
            // See SDK samples for examples
            // You should also define and filter the UI API events your addon will trap at this stage and create any menus
            // Call your routine to check if the required UDFs/UDTs exist on this company
            initialised = CheckInitialisation();
            if (!initialised)
               //  AddOn not yet intialised on this company so prompt the user to run the intialisation process
              int iResponse = app.MessageBox("The " + ADDON_NAME + " addon will now create all required fields and tables."
                                             + System.Environment.NewLine + System.Environment.NewLine
                                             + "WARNING: It is strongly recommended that all other users are logged out of this company "
                                             + "before running this process. Are you sure you wish to continue?", 2, "Yes", "No", "");
              if (iResponse == 1) initialised = InitialiseAddOn(); // Call your routine to create the objects
            return true;
    Kind Regards,
    Owen

  • What is the best way to transfer PDF files from my MacBook Air to my iPad2?

    I have updated both OS and trying to find an easy way to transfer pdf files to my iPad.  I have PDF expert on my iPad.

    easy
    install acrobat reader on your Ipad
    attach Ipad to your MAC with USB cable
    open Applications ON you Ipad thru ITUNES
    there is a BOX for Acrobat,..........drag and drop PDF from your MAC into that box of Acrobat for Ipad

  • Whats the easiest way to transport large files from my old laptop to my new ipad?

    can anyone tell me the easiest way or what app i need to transport file from my old lad top to my new ipad? im really not technical so the easiest way would be appreciated :)

    1. Install Dropbox on computer
    2. Copy all files to Dropbox in computer
    3. Install Dropbox on iPad; all files will be waiting for you there
    Note: you need a fast internet connection

Maybe you are looking for