How to convert a text data into xml data?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • asenthil
    New Member
    • Dec 2006
    • 61

    How to convert a text data into xml data?

    Hai to all...
    this is senthil....

    i want to convert a text data into a xml data....

    is there any source codes available in the net?

    or is there any methods, classes available for this type of conversion?

    Can any one plzz tell me?

    thanks
    senthil.
  • asenthil
    New Member
    • Dec 2006
    • 61

    #2
    Hai any one plzz explain me about this...

    i will explain u clearly what i have to do....

    Code:
    i'm having XML codings for creating a table in a mysql database...
    
    these xml codings are written into a single field in a database...
    
    what i have to do is...
    
    i have to write these xml codings into a file in which the file
    to be saved as xml file...
    Can any one plzz explain me

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by asenthil
      Hai any one plzz explain me about this...

      i will explain u clearly what i have to do....

      Code:
      i'm having XML codings for creating a table in a mysql database...
      
      these xml codings are written into a single field in a database...
      
      what i have to do is...
      
      i have to write these xml codings into a file in which the file
      to be saved as xml file...
      Can any one plzz explain me
      Well you asked for available codes which I do not have. I'm not very good at XML so the only way I can solve your problem is to "manually" create the XML
      using FileWriter class. How to do this would depend on the structure of data in the text file and the structure required for the XML file. If that is not good enough for you then maybe someone else who knows a conventional method of creating the XML file will be able to help you.

      Comment

      • asenthil
        New Member
        • Dec 2006
        • 61

        #4
        Hai r035198x,

        thanks for ur reply....

        i will explain u till clearly what i have to do...

        plzz give me some more hints after that

        Code:
        i'm having XML codings for creating a table in a mysql database...
        
        these xml codings are written into a single field in a database...
        
        what i have to do is...
        
        i have to retrive these xml codings into a file in which the file
        to be saved as xml file... 
        
        retriving is not a problem to me...
        
        But i have to save that retrived xml codings into a xml file...
        plzz give me some more hints..

        thanks..
        senthil..

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by asenthil
          Hai r035198x,

          thanks for ur reply....

          i will explain u till clearly what i have to do...

          plzz give me some more hints after that

          Code:
          i'm having XML codings for creating a table in a mysql database...
          
          these xml codings are written into a single field in a database...
          
          what i have to do is...
          
          i have to retrive these xml codings into a file in which the file
          to be saved as xml file... 
          
          retriving is not a problem to me...
          
          But i have to save that retrived xml codings into a xml file...
          plzz give me some more hints..

          thanks..
          senthil..
          Are these XML codings strings that you have to convert to XML tags?
          If so what is the structure of the strings(What tells you when a tag should be started and ended)?

          Comment

          • asenthil
            New Member
            • Dec 2006
            • 61

            #6
            No no...

            in the database....

            there is xml codings for creating a table with xml tags which is now just like
            the followilng
            <xml>
            <codings for creating a table>
            </xml>

            Only i have to retrive these codings(just like retriving an information)
            from the database and i have to write these codings into a file in which
            the file to be saved as xml file...

            can u get any idea...

            thanks
            senthil

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Originally posted by asenthil
              No no...

              in the database....

              there is xml codings for creating a table with xml tags which is now just like
              the followilng
              <xml>
              <codings for creating a table>
              </xml>

              Only i have to retrive these codings(just like retriving an information)
              from the database and i have to write these codings into a file in which
              the file to be saved as xml file...

              can u get any idea...

              thanks
              senthil
              I get the picture. I still don't think I'm the best person to help you on this but

              You said you can retrieve these codings. How are you retrieving them? As strings or some other data type?

              Comment

              • asenthil
                New Member
                • Dec 2006
                • 61

                #8
                Only i can retrive them as strings...

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Originally posted by asenthil
                  Only i can retrive them as strings...
                  if you can retrieve as strings then maybe this might help. It creates the file from an array of strings

                  Code:
                  import java.io.*;
                  public class WriteFile {
                           public static void main(String[] args) {
                  	try {
                  		File file = new File("test.xml");
                  		BufferedWriter out = new BufferedWriter(new FileWriter(file));
                  		String[] ss = {"<XML>", "<Test>", "</TEST>", "</XML>"};
                  		for(int i = 0;i < ss.length; i++) {
                  			out.write(ss[i]);
                  			out.newLine();
                  			out.flush();
                  		}
                  	}
                  	catch(IOException io) {
                  		io.printStackTrace();
                  	}
                      }
                  }

                  Comment

                  • asenthil
                    New Member
                    • Dec 2006
                    • 61

                    #10
                    Hai,

                    very very thanks for ur support and guidance....

                    i want to do some modifications in ur program,

                    bcoz i have to retrive that string from database...

                    i will try it and tell to u what the result is.

                    thanks...
                    senthil

                    Comment

                    • r035198x
                      MVP
                      • Sep 2006
                      • 13225

                      #11
                      Originally posted by asenthil
                      Hai,

                      very very thanks for ur support and guidance....

                      i want to do some modifications in ur program,

                      bcoz i have to retrive that string from database...

                      i will try it and tell to u what the result is.

                      thanks...
                      senthil
                      Welcome. Instead of the array and for loop you now sbstitute that with the values coming from the database.

                      Comment

                      • asenthil
                        New Member
                        • Dec 2006
                        • 61

                        #12
                        Hai r035198x
                        ur conditions worked supervly
                        when i used for writing a string into a file...

                        But when i tried to writed the string which is fetched from the database
                        it is not working....

                        But anyway i will do the second step surely....

                        basically i'm working in the field of VC++....

                        But ur codings gave me an idea to write a file...

                        Hereafter i will do my work well...

                        thanks for ur support
                        senthil

                        Comment

                        Working...