creating Xml

creating Xml

how we can create a xml file using java Creating XML File is possible in java with this packages. import... this Elemnts to DOcumnet object. Creating XML File is possible

View Answers

February 26, 2008 at 3:07 PM



Creating XML File is possible in java with this packages.

import org.w3c.dom.Document;
import org.w3c.dom.Element;

First try to get the
1.DocumentBuilderFactory object
2.with this Try to get the Document Object
3.With The Created Document Object ,try to add Your Elements by Element Object.
4. Appeng this Elemnts to DOcumnet object.


February 26, 2008 at 3:08 PM



Creating XML File is possible in java with this packages.

import org.w3c.dom.Document;
import org.w3c.dom.Element;

First try to get the
1.DocumentBuilderFactory object
2.with this Try to get the Document Object
3.With The Created Document Object ,try to add Your Elements by Element Object.
4. Appeng this Elemnts to DOcumnet object.


April 16, 2008 at 7:23 PM

Hi friend,

import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.io.*;

public class CountElementExample{
public static void main(String[] args) {
try {
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter File name: ");
String str = buff.readLine();
File file = new File(str);
if(file.exists()){
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// Create the builder and parse the file
Document doc = factory.newDocumentBuilder().parse(str);
System.out.print("Enter element name: ");
String element = buff.readLine();
NodeList nodes = doc.getElementsByTagName(element);
System.out.println("xml Document Contains " + nodes.getLength() + " elements.");
}
else{
System.out.print("File not found!");
}
}
catch (Exception ex) {
System.out.println(ex);
}
}
}

<?xml version = "1.0" ?>
<Employee-Detail>

<Employee>
<Id> E-001</Id>
<Emp_Name>Amardeep</Emp_Name>
<Emp_E-mail>[email protected]</Emp_E-mail>
</Employee>

<Employee>
<Id> E-002 </Id>
<Emp_Name>Anjali</Emp_Name>
<Emp_E-mail>[email protected] </Emp_E-mail>
</Employee>

<Employee>
<Id> E-003 </Id>
<Emp_Name>Sonu</Emp_Name>
<Emp_E-mail>[email protected] </Emp_E-mail>
</Employee>

<Employee>
<Id> E-004</Id>
<Emp_Name>Sandeep</Emp_Name>
<Emp_E-mail>[email protected] </Emp_E-mail>
</Employee>

<Employee>
<Id>E-005</Id>
<Emp_Name>chandan</Emp_Name>
<Emp_E-mail>[email protected]</Emp_E-mail>
</Employee>

<Employee>
<Id>E-006</Id>
<Emp_Name>suman</Emp_Name>
<Emp_E-mail>[email protected]</Emp_E-mail>
</Employee>

</Employee-Detail>


--------------------------









Related Tutorials/Questions & Answers:
Creating XMl file - XML
Creating XMl file   I went on this page: http://www.roseindia.net/xml/dom/createblankdomdocument.shtml and it shows me how to create an XML file, however there is something I don't understand. I have to create an XML file
creating document in XML - XML
creating document in XML  Create an XML document for catalogue of Computer Science Book in a Library.   Hi friend...)); System.out.print("Enter number to add elements in your XML file: "); String
Advertisements
creating index for xml files - XML
creating index for xml files  I would like to create an index file for xml files which exist in some directory. Say, my xml file is like below: smith 23 USA john 25 USA ... ... All xml files in the directory have
creating tables as an xml document - XML
creating tables as an xml document  Create a table of a medal tally of the Olympic Games as an XML document. The table must have the name...(); DocumentBuilder docBuilder = builderFactory.newDocumentBuilder(); //creating a new
creating Xml - Java Beginners
creating Xml  how we can create a xml file using java Creating XML... object. Creating XML File is possible  Creating XML File is possible... by Element Object.4. Appeng this Elemnts to DOcumnet object.  Creating XML
problem in creating web application using servelet, jsp, jdbc and xml - JSP-Servlet
problem in creating web application using servelet, jsp, jdbc and xml  Using Servlet, JSP, JDBC and XML create a web application for a courrier company to provide online help in tracking the delivery status of items.  
Hello World XML
to structure it. This tutorial explains creating xml and how to use css on it. You can use css to present xml data with styles. Creating XML: 1. Open any text... .style1 { background-color: #BFDFFF; } Hello World XML
XML
XML  How i remove a tag from xml and update it in my xml
xml
xml  why the content written in xml is more secure
xml
xml  validate student login using xml for library management system
xml
xml  validate student login using xml for library management system
xml
xml  what is name space,xml scema give an example for each   XML Namespaces provide a method to avoid element name conflicts.They are used for providing uniquely named elements and attributes in an XML document
XML Syntax Rules
XML Syntax Rules       The syntax  rules  for  XML are very simple and strict. These  are  easy to learn and  use. Because of this, creating software
XML
XML  please tell me how i remove one tag out of all similar type of tags in xml
xml
xml  how can i remove white space and next line when i copy stream to xml file
XML
XML  create flat file with 20 records. Read the records using xml parser and show required details
xml
xml  what is xml   Extensible Markup Language (XML... that is both human-readable and machine-readable. It is defined in the XML 1.0... gratis open standards. The design goals of XML emphasize simplicity, generality
XML
XML  Hi...... Please tel me about that Aren't XML, SGML, and HTML all the same thing?ADS_TO_REPLACE_1 Thanks
XML
XML  Design an XML to maintain book details to do the following: (i) Separate Data (ii) Exchange Data (iii) Store Data (iv) Create new language
xml
xml  Design an XML to maintain book details to do the following: (i) Separate Data (ii) Exchange Data (iii) Store Data (iv) Create new language
Creating an Applet
Creating an Applet  Hi, I have get a task regarding Creating an Applet using all Layout Manager, can anyone help me in this regard. I donā??t know how to make and please help me. Thanks.   To answer of your query
Creating Views
Creating Views Struts provides their own JSP tag library for creating view. For using those library you need to import them on your page as <%@taglib... data by model and handle them appropriately. For creating a view you should
XML - XML
XML  What is specific definatio of XML? Tell us about marits and demarits of XML? use of XML? How we can use of XML?  Hi, XML... language much like HTML used to describe data. In XML, tags are not predefined
Creating Exception
Creating Exception  class Myexception extends Exception{ private int detail; Myexecption(int a){ detail=a; } public String toString(){ return "Myexception["+detail+"]"; } } class Exceptiondemo{ static void Compute(int a) throws
Open Source XML Editor
Open Source XML Editor Open source Extensible XML Editor The Xerlin Project is a Java? based XML modeling application written to make creating... for developers interested in creating a UI for working with XML data files. Xerlin
XML - XML
XML XSD validation in java  Can anyone help in writing validation for XML XSD in Java
XML - XML
XML  How to run XML program?  Hi Friend, Please visit the following links: http://www.roseindia.net/xml/ http://www.roseindia.net/xml/dom/ Hope that it will be helpful for you. Thanks
JAXB Create XML File And Get Data From XML
JAXB Create XML File And Get Data From XML In this section we will read about how to create XML file and how to convert XML file's data to Java Object using JAXB. Since we are going to do work with the XML files and using JAXB
Creating a memory leak with Java
Creating a memory leak with Java  Creating a memory leak with Java
XML - XML
XML  How to convert database to XML file?   Hi Friend, Do you want to store database data into xml file ? Please clarify this. Thanks
Creating a Frame
, calender, combobox checkbox and many more for creating GUI in Java based... with your applet. Swing libraries is used for creating desktop applications...; Creating a Frame     
xml - XML
xml  how to match to xml file?can you give example with java code
xml - XML
friend, XPath : It is a language for finding information in an XML document. It is used to navigate through elements and attributes in an XML document. It is a language for selecting nodes from an XML document. It is used
Generate xml
Generate xml  hi can i generate xml file with xsd using JAXP in java. if possible please send java code. Thanks.   Please visit the following link: http://www.roseindia.net/xml/creating-xml-tree.shtml
Creating XML Tree
Creating XML Tree      ... API for XML Processing) is an interface which provides parsing of xml documents... to result. There are some of the methods used in code given below for Creating
xml developing - XML
creating final XML, if i make any modification to original xml (i.e. " operation...xml developing  I want to develop XML document with following DTD file with XML format. I have also XSL file as a externatl file to represent my xml
xml developing - XML
creating final XML, if i make any modification to original xml (i.e. " operation...xml developing  I want to develop XML document with following DTD file with XML format. I have also XSL file as a externatl file to represent my xml
Tags in XML - XML
Tags in XML  What are the Tags of XML  In XML there is no predefined tag. Every user can write their own tags at the time of creating it or later. You can define as many tag as you want according to your requirement
xml - XML
xml  hi convert xml document to xml string.i am using below code... = stw.toString(); after i am getting xml string result, like Successxxx profile... Friend, Please visit the following link: http://www.roseindia.net/xml/reading
xml - XML
xml  define parser and xml,in jaxp api how to up load parsers... then the program contains syntax errors. XML is defined as an extensible... information,Examples and Tutorials on Xml visit to : http
xml - XML
xml  hi convert xml file to xml string in java ,after getting the xml string result and how to load xml string result? this my problem pls help..."); FileOutputStream output = new FileOutputStream("new.xml"); ReadXML xml = new
to creating a registration form
to creating a registration form  how to create a registration form
creating windo chat
creating windo chat   hi ... please could you help me in creating chat aprograme in java ???? with comments beside codes please
Consolidated XML to individual XML - XML
Consolidated XML to individual XML  How to separate the consolidated XML file to separate the individual XML names, when a user import the consolidated XML file
XML - XML
XML  Write a program using SAX that will count the number of occurrences of each element type in an XML document and display them. The document file...)); System.out.print("Enter XML file name:"); String xmlFile = bf.readLine
Creating circle inside a circle
Creating circle inside a circle  hi can any one give code for following output by awt/swing creating circle inside a circle ,outside cirlce and intersect a circle
Creating PDF in JAVA
Creating PDF in JAVA  How create pdf in java ? Take value from database for particular PDF
creating inheritance of cars
creating inheritance of cars   hi ... please help me in creating inheritance between some types of cars like car that is parent and both of private car and public car are extends it then bus and truck extends public car
creating reports in java
creating reports in java  how to create reports automatically in java and send it via mail by scheduling tine for weekly,monthly basis
Creating a setup file
Creating a setup file  How to create a setup file in tomcat as done in visual studio... could plz tell me as early as possible

Ads