Skip to Content
avatar image
Former Member

Convert xml to xmldom object

Hi frnds

I need your help as m not a java programmer so m getting a problem in the respective scenario..

I have to write a java program which accept xml as a string and convert xml string to xml dom object, and create a xml file using the xml dom object.

i have done some coding for accepting the xml file and print it on the console that is as like..

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

class XMLConverter

{

public static void main(String args[])

{

String XML_FOLDER_NAME="D:/java/client.xml";

String selectXMLFile="";

try

{

BufferedReader in1 =new BufferedReader(new FileReader(XML_FOLDER_NAME));

String str1 = "";

while ((str1 = in1.readLine()) != null)

{

System.out.println(str1);

}

}

catch (Exception e)

{

System.out.println("Exception: " +e);

}

}

}

But hw to convert xml string to xml dom object and the further evaluation. Plz help me out.

Thnx

Adhir

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jul 31, 2007 at 10:16 AM

    Hi Adhir,

    These two links from java.sun.com may help you.

    First one is about Reading XML Data into a DOM.

    1.http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/dom/1_read.html

    Second is about Writing Out a DOM as an XML File

    2.http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/xslt/2_write.html

    Best Regards,

    Nitesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 06, 2007 at 07:12 AM

    Hi,

    Please check this link. It will be useful.

    http://www.brics.dk/~amoeller/XML/programming/domexample.html

    Note: http://www.brics.dk/~amoeller/XML/xml/recipes.xml - XML file used by the sample program

    Regards,

    Dhanasekar K

    Reward points if found useful

    Add comment
    10|10000 characters needed characters exceeded