vasu
creating Xml
3 Answer(s)      5 years and 3 months ago
Posted in : Java Beginners

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>amar@rediffmail.com</Emp_E-mail>
</Employee>

<Employee>
<Id> E-002 </Id>
<Emp_Name>Anjali</Emp_Name>
<Emp_E-mail>anjali@yahoo.com </Emp_E-mail>
</Employee>

<Employee>
<Id> E-003 </Id>
<Emp_Name>Sonu</Emp_Name>
<Emp_E-mail>sonu38@yahoo.com </Emp_E-mail>
</Employee>

<Employee>
<Id> E-004</Id>
<Emp_Name>Sandeep</Emp_Name>
<Emp_E-mail>sonu3@yahoo.com </Emp_E-mail>
</Employee>

<Employee>
<Id>E-005</Id>
<Emp_Name>chandan</Emp_Name>
<Emp_E-mail>ravi@rediffmail.com</Emp_E-mail>
</Employee>

<Employee>
<Id>E-006</Id>
<Emp_Name>suman</Emp_Name>
<Emp_E-mail>suman@rediffmail.com</Emp_E-mail>
</Employee>

</Employee-Detail>


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









Related Pages:
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
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
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 in database - XML
XML in database  Hi Deepak, i m again facing problem with single element multiple tag in xml. i m trying to read the tag values into my... this xml into my db(which is in mysql) i write the following code. import
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
How to create XML file - XML
How to create XML file  Creating a XML file, need an example. Thanks!!  To create XML file you need plain text editor like note pad. After creating your file save it with .xml extension.  Hi,Java programming
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
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.  
DOM - XML
DOM  Hello.... I'm creating an xml file from java using DOM... from the database values... and saving it in a file But the created xml file..."),rs.getString("email")); } System.out.println("Xml File Created
XML Schema
. They are extensible as they are written in XML Simple xml document, creating dtd and schema...: #FFFFFF; } XML Schema An XML Schema defines how to structure an XML document and it can be used in place of DTD. XML Schema is based on XML. XML Schema
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
Creating files in jpa project
Creating files in jpa project       After creating "JPACRUDApplication" project...; folder and ritht click on it. Select New => 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
Creating a DTD
.style1 { background-color: #FFFFFF; } Creating a DTD A document type definition (DTD) is used to validate XML files that reference the DTD file... etc for any XML file and defines constraints for how each element, attribute
Hibernate Creating criteria instance
Hibernate Creating criteria instance In this section you will learn about the creating of criteria instance in Hibernate. An instance of Criteria is created... cellphone) { this.cellphone = cellphone; } } Worker.hbm.xml <?xml
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
Mapping objects in XML - Spring
an object in the configuration XML as follows: tom... the object... How can I define the XML? I don“t understand the utility about creating abjects in this "restricted" way, using always the same parameters... Ok
xml creation in java
xml creation in java  HI, I need a java program to create an xml file... therez a tutorial in your site to create an xml file at http://www.roseindia.net/xml/dom/CreatXMLFile.shtml but this isn't creating a file, its just
Creating Blank DOM Document
Creating Blank DOM Document      ... API for XML Processing) is a Java interface that provides a standard approach to Parsing XML documents. With JAXP, we will use the Document BuilderFactory
XML
XML  How i remove a tag from xml and update it in my xml
XML Related Technologies: An overview
) is a language for creating hyperlinks in XML documents. XPointer (XML Pointer... XML Related Technologies: An overview       Below is a list of XML-related technologies. DTD
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, XML Tutorial, XML Tutorial Online, XML Examples, XML Tutorial Example
XML XML Tutorials and examples In this section we will learn XML with the help of tutorials and example code. If you are a beginner in XML then learn it step-by-step following through all the tutorials given here. About XML
XML Tutorials
; Creating Xml Tree This Example... for parsing, creating, manipulating, and serializing XML documents, it is a tree... XML Tutorials      
XML
XML  Hi...... Please tel me about that Aren't XML, SGML, and HTML all the same thing? Thanks
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  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 InlineStreamFilter
Creating an InlineStreamFilter      ... API for XML Processing) is an interface which provides parsing of xml documents. There are some of the methods used in code given below for Creating a Filter
DOM Example For Creating a Child Node 
DOM Example For Creating a Child Node  In this section we will discuss about how to add a Child Node in Dom document. The addition of child node...;java createchild <?xml version="1.0"encoding="UTF-8
XMl
xml
xml
Creating Custom Component using MXML
; margin-top: 0in; } Creating Custom Component using MXML   Creating...: MyMXMLCustomComponent.mxml   <?xml version="1.0"... in mycomp package.   <?xml version="1.0"
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
XML Interviews Question page7,xml Interviews Guide,xml Interviews
XML Interviews Question page7       If XML is just a subset of SGML, can I use XML... needed to support XML, such as the variant form for EMPTY elements; some aspects
XML - XML
XML XSD validation in java  Can anyone help in writing validation for XML XSD in Java
Java Generate XML Example
rootElement.appendChild(ChildElement); 7. Create the output formate // Creating XML output...(document); An example for creating the XML in Java is given below package...(); collegeElement.appendChild(faculity); // Creating XML output format OutputFormat
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.