java and xml problem. plz see this 1 first
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>xxx</Username>
<Password>xxx</Password>
</AuthHeader>
</soapenv:Header>
<soapenv:Body>
<ocs:doService>
<ocs:in0>
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<zsmart>
<Data>
<header>
<ACTION_ID>ModDefLang</ACTION_ID>
<REQUEST_ID>002009031100001</REQUEST_ID>
</header>
<body>
<MSISDN>22508591226</MSISDN>
<UserPwd></UserPwd>
<DefLang>1</DefLang>
</body>
</Data>
</zsmart>
]]>
</ocs:in0>
</ocs:doService>
</soapenv:Body>
</soapenv:Envelope>s
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. plz see this 1 first - XMLjava and
xml problem.
plz see this
1 first hi, i need to write a
java program that generates an
xml file as follows:
xxx... in your
XML file: ");
//String str = bf.readLine();
int no = Integer.parseInt("
1 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
Advertisements
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...
XML file: ");
//String str = bf.readLine();
int no = Integer.parseInt("
1 XML load problem - XML,
Plz give full details with source code to solve the
problem and visit to :
http://www.roseindia.net/
xml/dom/
Thanks
New Document...
XML load problem I have load the
xml document in javascript.getting
xml problem - XMLxml problem URGENT>>>>>
how to retrieve data from hash tables without a JDBC connection??????
Thanks & Regards
SAIBHARGAV146
What to See in Jaipur in 1 Day?We are discussing about the important places that visitors must
see in one day trip to Jaipur.
A planned trip is something that one does not always get, but that does not imply that unprepared trips are pathetic experiences unless you
SEE with Java
SEE with
Java
Position Vacant:
SEE with
Java
Job Description
Java...:
SEE with
Java facing problem plz help me out - FrameworkFacing
problem plz help me out hi i am new to servlet i deployed... the web.xml file too parallel to the classes folder now i am facing this problem.plz tell me what to do... error:The requested resource (Servlet servlet
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... FileOutputStream(lsPath+"\\Test.xml");
// XERCES
1 or 2 additionnal
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
plz help me today plz plz - Java Interview Questionsplz help me today
plz plz 2.) Suppose list is an array of six elements of type int. What is stored in list after the following
java code executes... int[5];
alpha[0] = 5;
for (count =
1; count < 5 * count ++)
{
alpha[count
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
Plz send - Java BeginnersPlz send Hi,
please send whole code i understood ur sending... be a troublesome...then again wat r ur needs....
so
plz...provide a deatiled structure of ur
problem....
thanks and reg/
prashu..
[email protected] 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 application PLZ ?Java application
PLZ ? Write an application that demonstrates each of the following methods, based on the statement String dedicate = ?Dedicated to making your event a most memorable one:; indexOf(?D?)
charAt(15)
endsWith(one
Plz give java coding for thisPlz give
java coding for this ... iMin =
1, iMax = 8, iMid; // give max. value in even no.
int jMin =
1, jMax...;& j < jMid)
|| (i == iMax -
1 && j > jMid
java coding help plz ?java coding help
plz ? Given two integers N and M (N � M), output all the prime numbers between N and M inclusive, one per line.
N and M... (i >
1) {
if ((number != i) && (number % i
plz help - Java Beginners Thread in
java :
First Code :
import java.io.PrintWriter;
import...
plz help i have to programs and it takes too long to run them so i.....
but i dont know how to aplly that on my 2 programs:
the
first code
Plz answer - Java BeginnersPlz answer Create a
Java Bean Class â?? Customer according to the below given class diagram.
Customer...
-------------------------------------------------
plz doreply me....thankz alot
java tree expressions - XMLjava tree expressions hi all,
i have a
problem in tree expressions.
see there is a document tree like a parent document has no. of child... code to solve the
problem and visit to :
http://www.roseindia.net/
java plz answer - Java Beginnersplz answer Write a Binary Search program that searches an array... the following series of numbers and run the search on it:
1, 2, 3, 5, 8, 13, 21, 34, 55..., f2 = 0, f3 =
1;
for (int i = 0; i < intArray.length; i++) {
f1 = f2;
f2
plz send immediately - Java Beginnersplz send immediately Hi Deepak,
How are you,
Deepak I face some
problem in my project,
plz help me
My Questin is user input... should be updated.
plz write a code and immediate response its very urgent
plz plz - Java Interview Questions is between
1 and 6 (inclusive).
design and implement a class , called die , to represent a die .the default constructer should initialize a die to the number
1 .your class must contain the method rollDie that returns a number between
1 plz help me - Java Beginnersplz help me Thanks deepak continue response..i face some
problem
i hv a these file index.jsp,sessionvalid.jsp, both r store in project folder... is true...but i very confuse that how it is not displayed admin page
plz any one
plz help me - Java Interview Questionsplz help me
1)Rewrite the method in exercise 10 such that it use...; if they are not equal , the
problem is reduced to searching half of the array
. if the search value is smaller than the middle array element, the
first half
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
plz help me - Java Beginnersplz help me Deepak I can write a sessioon code
plz help me admin_home.jsp page is display but data is not disply
plz help me what is wrong
plz help me - Java Beginnersplz help me Hi,
I want to search all field from database using name, and display in text box, then data is update and delete.
i want to search name using alphabets a-z,
plz reply fast.
plz help me this is very urgent
plz help - Java Interview Questionsplz help
1)write a
java program that prompts the user to input a decimal number and print the number rounded to the nearest integer?
2)write... don't use "for" Hi Friend,
Try the following code
1)
import
help plz - Java Interview Questionshelp plz
1 )write a program that does the following :
a. prompts... , if the input string is abcd, the output is : edcba
plz plz plz plz plz help me Hi Friend,
Try the following:
1)
import java.util.
plz Help me - Java Beginnersplz Help me Hi,
I want learn struts,I dont have any idea about this
plz help how can i make a framework.If u have any information then
plz send my personal id
plz tell me that whose software installed.and give me brief
java code7 of 1java code7 of
1 Develop the program calculateHeight, which computes the height that a rocket reaches in a given amount of time. If the rocket accelerates at a constant rate g, it reaches a speed of g �· t in t time units
java code 8 of 1java code 8 of
1 Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time
java code 1 of 2java code
1 of 2 Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes
Hi Friend,
Visit
task 1 - Java Beginnerstask
1 Please write a
Java client that send a small letters string to a
Java server which convert it to uppercase letters and send it back to the client. Please submit both the client and server programs Hi Friend
java program 1java program
1 (4) WAP to take input of a String and check wheather it is valid number or not?
Sample Output1:
Enter a String : 10
10 is a number
Sample Output2:
Enter a String : 10b1
10b1 is not a number
(5) WAP to take
java code 1 of 2java code
1 of 2 Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes
Hi Friend,
Try