java and xml problem
hi, i need to write a java program that generates an xml file as follows:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ocs="http://ocs.ztesoft.com">
<soapenv:Header>
<AuthHeader xmlns="http://ZTE.com/webservices/">
<Username>aaa</Username>
<Password>vvv</Password>
</AuthHeader>
</soapenv:Header>
<soapenv:Body>
<ocs:doService>
<ocs:in0>
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
---------
i have witten a program in java, but im not getting the same format as it is here. this is what i have written
import java.io.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import org.w3c.dom.*;
public class CreatXMLFile {
public static void main(String[] args) throws Exception {
//BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
//System.out.print("Enter number to add elements in your XML file: ");
//String str = bf.readLine();
int no = Integer.parseInt("1");
//System.out.print("Enter root: ");
//String root = bf.readLine();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
Element rootElement = document.createElement("zsmart");
document.appendChild(rootElement);
Element child = document.createElement("Data");
rootElement.appendChild(child);
Element child1 = document.createElement("Header");
rootElement.appendChild(child1);
Element child2 = document.createElement("ACTION_ID");
child.appendChild(child2);
Text text = document.createTextNode("ModDefLang");
child2.appendChild(text);
//Comment comment = document.createComment("Employee in roseindia");
//child.appendChild(comment);
Element element = document.createElement("REQUEST_ID");
child.appendChild(element);
Text text1 = document.createTextNode("002009031100001");
element.appendChild(text1);
/* Element chilE = document.createElement("Id");
chilE.setAttribute("name", "Vineet");
rootElement.appendChild(chilE);
Text text12 = document.createTextNode("status");
chilE.appendChild(text12);*/
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// create string from xml tree
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(document);
transformer.transform(source, result);
String xmlString = sw.toString();
File file = new File("c:/newxml.xml");
BufferedWriter bw = new BufferedWriter
(new OutputStreamWriter(new FileOutputStream(file)));
bw.write(xmlString);
bw.flush();
bw.close();
}
}
---------
the output i am getting is as follows.
<?xml version="1.0" encoding="UTF-8"?>
<zsmart>
<Data>
<ACTION_ID>ModDefLang</ACTION_ID>
<REQUEST_ID>002009031100001</REQUEST_ID>
</Data>
<Header/>
</zsmart>
can you plz help...
View Answers
Related Tutorials/Questions & Answers:
java and xml problem - XMLjava and
xml problem hi, i need to write a
java program that generates an
xml file as follows:
aaa
vvv
---------
i have witten a program in
java, but im
XML load problem - XMLXML load problem I have load the
xml document in javascript.getting...,
Plz give full details with source code to solve the
problem and visit to :
http://www.roseindia.net/
xml/dom/
Thanks
New Document
Advertisements
xml problem - XMLxml problem URGENT>>>>>
how to retrieve data from hash tables without a JDBC connection??????
Thanks & Regards
SAIBHARGAV146
Problem with external DTD - XMLProblem with external DTD Hi,
This class generate an
XML file.But while I am running that generated
xml file its giving error as can not locate... classes.
OutputFormat of = new OutputFormat("
XML","ISO-8859-1",true);
of.setIndent
Xml append node problem Xml append node
problem print("code sample");Question:
I create a
XML which looks like this:
<cwMin>31</cwMin>
The code used in generating this
XML is :
XMLOutputFactory xof
jasper problem - XMLjasper problem URGENT
PROBLEM!!!!!!!!!!!!!
how can we use a hash table in jasper reports to generate reports without using database connection directly
but access data from the hash table what we needed for creation
Problem facing in SAX Parsing - XMLProblem facing in SAX Parsing I have facing the issue in SAX Parsing like i have got the
xml and the
xml structure is like below... can find the above
xml there is no CountryCode in the second record and 4th
Problem facing in SAX Parsing - XMLProblem facing in SAX Parsing I have facing the issue in SAX Parsing like i have got the
xml and the
xml structure is like below...
0668420957700159USD
you can find the above
xml java and xml - XMLjava and xml
test_final_1
2009-025T13:23:45
B2B
I... this
problem... Hi Friend,
Please visit the following link:
http://www.roseindia.net/
xml/dom/DOMValidateDTD.shtml
Thanks
Java-XML-DOM - XMLJava-
XML-DOM Hi! I need some help. I have to make
java program that loads an
xml file and from it builds DOM(later i will have to work.... If there is someone out there that knows
java very well, this wouldn't be a
problem for him
java with xmljava with xml hi
i have a
problem.
// this sample code is reading
xml file in
java
DefaultHandler handler = new DefaultHandler... example i copmpare qName with NAME. NAME is
xml element. but my
problem is when
java Problemjava Problem I want to create a binary tree for displaying members in Downline. i am creating a site for MLM(Multi-Level MArketing). tree must be dynamically populated from database. is there any help for me.
Thanks in advance
JAVA ProblemJAVA Problem Write a program that takes two parameters
1. a word
2. an array of words
It should then remove all instances of the word in the array.
For Example:
INPUT
word="ravi"
word_array = ["Chethan Bhagat
Java + XML - XMLJava + XML 1) I have some
XML files,
read one
xml...
java...the attribute value..not sure now how to read the
xml file passing..." pointing to a hello
xml file ..read that file and get the value of the parent
java and xml - XMLjava and xml Hi Deepak,
I want learn
xml and
java(applications).
Which editor is best usefull(trial--version) in my applications...; Hi friend,
http://www.roseindia.net/
xml/dom/
Thanks
Read XML in java - XMLRead
XML in java Hi Deepak, I want to read a
xml file which have...
nikumbh
i tried to solve the
problem but failed.the program which i hav... a solution.my
java code is given below.
import java.io.File;
import
XML with JAVA - XML document and the processing in
JAVA program . Find the time for each
XML element...
XML with JAVA Hi..
This is Priya here. Thanks for responding me. I have a query.
"Write program in
java to evaluate the time to access
resolution problem in javaresolution
problem in java I designed project in
java in my PC when run the same project in some other PC i can't fully view my
java forms.Some said that it is resolution
problem XML parsing using Java - XMLXML parsing using Java I'm trying to parse a big
XML file in
JAVA..." in element "MIRate"(THE
XML code is below).once he enters coverage rate I need..." RenewalRate1="0.03100".
I'm facing
problem switching between tables. Like
java with xmljava with xml Hi
i am reading
xml data with sax parser in
java. ok its fine. But in future xsd and
xml will change. now my question is if xsd and
XML will change my
java progrm will not change. is it possible ?
Thanks
java with xmljava with xml Hi
i am reading
xml data with sax parser in
java. ok its fine. But in future xsd and
xml will change. now my question is if xsd and
XML will change my
java progrm will not change. is it possible ?
Thanks
XML in java - XMLXML in java Write a program using SAX that will count the number of occurrences of each element type in an
XML document and display them...://www.roseindia.net/
xml/sax/SAXElementCount.shtml
Hope that it will be helpful
java - XML
This is my
XML file then how can read this
XML file Using DOM & SAX parsers in
java?
How can write the same data into
XML file using DOM parser?
Could you
Problem in uploading java applicationProblem in uploading
java application I have uploaded my
java application (folder created under webapps) using Filezilla FtpClient.Application... this
problem for a problem in coading - Java Beginnersfor a
problem in coading what is the problm in following coading...(String[] args)
{
mywindow ();
}
}
Hi Friend,
There is no
problem... mywindows.java
Run :
java mywindows
Thanks
RoseIndia Team
java tree expressions - XMLjava tree expressions hi all,
i have a
problem in tree expressions... code to solve the
problem and visit to :
http://www.roseindia.net/
java... documents.
the
problem is whenever i click on + sign it means it will have surely have
Multiplication problem - Java BeginnersMultiplication problem I am facing a peculiar
problem in
java regarding a multiplication. Please see below:
19300 * 0.001 = 19.3
19400 * 0.001 = 19.400000000000002 (why is this ??)
19500 * 0.001 = 19.5
Can anybody help
code problem - Java Beginners
java script
j2ee
j2me
sql
plz help me to sort out this
problem.
thnx
...code problem Dear sir,
I'm havin a
problem that suppose i've got a file that contains the following lines-
java
java script
j2ee
php
sql
java - XMLjava How can write data into
XML file using DOM parser?
How can convert HTWL file to
XML file
Problem on JAVA ProgrammeProblem on
JAVA Programme public class AA {
int add(int i) {
int y = i;
y += 20;
if (y <= 100){ y +=30;add(y);}
System.out.println("Final Value of y : " + y);
return y;
}
public static void main
JAVA CLASSPATH PROBLEMJAVA CLASSPATH PROBLEM hi all Friends
I am stuck using the
java servlets and
problem raise for classpath.
I had a
problem with servlet to call... that it didn't found any
java class (which is
java class calling from servlet).
but i
how to update xml from java - XML friend,
To solve your
problem, please visit to:
http://www.roseindia.net/
xml...how to update
xml from java hi, Im new to
xml parsing and dont know much about.
I need to modify the attribute val of a tag in a complex
xml file
java - XMLjava how can i validate my
xml file using
java code plz send me de... kumar Hi friend,
Step to validate a
xml file against a DTD (Document Type Definition) using the DOM APIs.
Here is the
xml file "User.xml
Java Problem - Java BeginnersJava Problem Write a program 2 input a positive integer n and check wheter n is prime or not and also know the position of that number in the prime...,
Code to solve the
problem :
import java.io.*;
public class PrimeNumber
XML and javaXML and java Hi
I have
xml data in XMLStreamreader object how to retrive tha data and write into a file using
java
Your help will be much appreciated
Thanks
Hi Friend,
Try the following code:
import java.io.
java - XMLjava How to prepare an
xml document by reading data from a table in the database .
(the database access logic is written inside the servlet
java - XML you get the data3. And in the servlet class you can use the DOM api to create
xml... it to the
xml treedoc.appendChild(root);For more information please visit http://www.roseindia.net/
xml/dom/createdomchildelement.shtmlThanks
Java implementation problem/answers/viewqa/
Java-Beginners/28578-java-implementation-
problem-.html...
Java implementation problem I want to implement following in
java...
problem in your post previews.
please consider
1. 2. points just after main
code problem - Java Beginners; Hi friend,
Code to help in solving the
problem :
import java.io.... in
Java visit to :
http://www.roseindia.net/
java/example/
java/io/
Thanks
java implementation problem java implementation
problem I want to implement following in
java code :
Main thread
Create three threads
wait for completion of stage 2 of all three threads
Access all three local variable (LC0, LC1, LC2) of threads
bulid
problem 1 - Java Beginnersproblem 1 Hi,
please help me!!!! How can i code in
java using Two-dimensional Arrays? This question is related to the one i posted before. this is my input data file:
88 90 94 102 111 122 134
75 77 80 86 94 103 113
80
code problem - Java Beginnerscode problem Dear sir,
I have an excel file in D: drive called today.xls, i want to open it thru
java program, what code would be compatible plz help me Hi friend,
Code to help in solving the
problem :
import
Basic problem for Java expertsBasic
problem for
Java experts This assignment will test your knowledge of
Arrays
Array searching
Array sorting
Array processing
Specification
An athletics club require a simple statistical analysis program for analysing lap
problem with main - Java Beginnersproblem with main
import javax.swing.*;
import java.awt.... a
problem. when i compile it appears this message:
java.lang.NoSuchMethodError: main... it with html file.
applet.html:
Java Applet Demo
Thanks
java - XML in the
XML document while i am parsing the file using SAX event based parser.... provide the way in
java. Hi Friend,
Try the following code:
import... parser = parserFact.newSAXParser();
System.out.println("
XML Data
code problem - Java Beginnerscode problem Dear sir,
my
problem is that I've a string value if this String value has "quit" then output should be "bye". i want to make this program using SWITCH CASE statement. how to implement String value in Switch plz