Using XML in Java

Author Topic: Using XML in Java  (Read 2000 times)

Offline HomeTopic starter

  • Trade Count: (0)
  • Newbie
  • *
  • Thank You 0
  • Posts: 3
  • Karma: 0
Using XML in Java
« on: 01-21-2011, 02:10:10 »
Please tell me how to implement this.


Offline ravi

  • Trade Count: (0)
  • Semi-Newbie
  • *
  • Thank You 0
  • Posts: 23
  • Karma: 0
    • Seo Manual Submission
Re: Using XML in Java
« Reply #1 on: 10-11-2011, 04:02:52 »
i have no knowledge about this....plz mentioned it.......

Offline navkesh

  • Trade Count: (0)
  • Semi-Newbie
  • *
  • Thank You 0
  • Posts: 29
  • Karma: 2
    • Copenhagen Tours
Re: Using XML in Java
« Reply #2 on: 09-15-2012, 12:38:40 »
XML is an enabling technology for the virtuous programmer. A basic XML parser does a great deal of work for the programmer, recognizing tokens, translating encoded characters, enforcing rules on XML file structure, checking the validity of some data values, and making calls to application-specific code, where appropriate. In fact, early standardization, combined with a fiercely competitive marketplace, has produced scores of freely available implementations of standard XML parsers in many languages, including C, C++, Tcl, Perl, Python, and, of course, Java.

The java.util.Properties class has build-in functionality to convert properties file into XML file or vice verses.

Example:
Convert properties file into XML file in JAVA

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;
 
public class PropertiesXMLExample
{
    public static void main(String[] args) throws IOException
    {   
       Properties props = new Properties();
       props.setProperty("email.support", "donot-spam-me@nospam.com");
       OutputStream os = new FileOutputStream("c:/email-configuration.xml");
       props.storeToXML(os, "Support Email","UTF-8");
       System.out.println("Done");
    }
}

The above example will write the properties detail into a XML file “c:/email-configuration.xml“ as:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
   <properties>
      <comment>Support Email</comment>
      <entry key="email.support">donot-spam-me@nospam.com</entry>
   </properties>

Offline netedge12

  • Trade Count: (0)
  • Newbie
  • *
  • Thank You 0
  • Posts: 6
  • Karma: 0
Re: Using XML in Java
« Reply #3 on: 10-18-2012, 03:21:05 »
XML could be a all-purpose specification for making custom mark-up languages. Its primary purpose is to assist info systems share structured knowledge, significantly via the net, and it's used each to code documents and to set up knowledge.
« Last Edit: 10-18-2012, 04:24:36 by Sevam »

 

Related Topics

  Subject / Started by Replies Last post
7 Replies
2647 Views
Last post 06-04-2015, 11:41:09
by MarcoLeitner
0 Replies
1952 Views
Last post 04-22-2013, 22:55:07
by Hi-Tech ITO
0 Replies
2084 Views
Last post 05-06-2013, 00:57:33
by geeky
2 Replies
1307 Views
Last post 06-11-2015, 13:21:15
by MarcoLeitner
0 Replies
331 Views
Last post 06-04-2015, 06:42:14
by Lisbently