473,469 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to copy the contents an incoming XML from an application and store it in a file

3 New Member
I need to copy the contents of an incoming XML from an application into a file present at another location. This incoming XML is being using XMLStreamReader and is being stored in the HashMap table. The commands used are reader.getAttributValue(), where reader is the object of XMLStreamReader.
Note: Since the incoming XML is from an application, it doesn’t have a fixed location (JMETER/JBOSS is being used).
May 10 '10 #1
6 3092
jkmyoung
2,057 Recognized Expert Top Contributor
"This incoming XML is being using XMLStreamReader and is being stored in the HashMap table."
Please clarify: Are you storing the xml into the file as it was, or are you restructuring the output in some different way?

Trying to figure out what part you're having troubles with:
1. Writing to a file?
2. Converting the Hashmap to an output stream?
3. XML output problems? (eg namespace)
May 10 '10 #2
Sujatha0105
3 New Member
@jkmyoung
Since the XML is coming from another application, it is not stored anywhere, and what I am trying to do is write it on to a file and store it at a location.

To answer to your question, I am facing trouble in writing the incoming XML to a file.
May 11 '10 #3
Dheeraj Joshi
1,123 Recognized Expert Top Contributor
What problem you are facing?

Regards
Dheeraj Joshi
May 11 '10 #4
Sujatha0105
3 New Member
This is what i have tried..

FileWriter F2 = new FileWriter("../inputlog/1.log");
BufferedWriter D2 = new BufferedWriter(F2);
while (reader.hasNext())
{
if (log.isDebugEnabled())
{
log.debug("input xml value:" + reader.getText());
}
String a1 = reader.getText();
D2.write(a1);
// some other code is present here
.
.
.
reader.next();
}
F2.close();

Can I know what’s wrong in the above code

Note:
1) reader is an object of XMLStreamReader
2) Also the file "1.log" gets created but doesn’t have any Data
3) The entire system is in UNIX
May 11 '10 #5
Dheeraj Joshi
1,123 Recognized Expert Top Contributor
Is this the complete code?

I can not see D2.close() being called. You need to close D2.

Regards
Dheeraj Joshi
May 11 '10 #6
jkmyoung
2,057 Recognized Expert Top Contributor
http://java.sun.com/webservices/docs...eamReader.html
getText() is not always valid depending on where you are in the document. This is not like a bufferredReader where you can just call next() or nextLine(). From the page:
"The XMLStreamReader is designed to iterate over XML using next() and hasNext(). The data can be accessed using methods such as getEventType(), getNamespaceURI(), getLocalName() and getText();"

Basically your output relies on the state you are in:
Switch on next(){
output current value in different ways, depending on your state.
}

Use a XMLStreamWriter to make it easier: Why rewrite code if you don't have to?
May 11 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: adirajuv | last post by:
I wrote a program in VC++ long time ago and I lost my code and all the intermediate files. All I have is the "exe" file that was generated when I executed it. Can the code be retrieved from this...
6
by: Khuong Dinh Pham | last post by:
How do i read the contents of a xml file and output it to a std::string. Thx in advance
6
by: Ann Marinas | last post by:
Hi, all! I have a question regarding application config files. Is there a possibility that a value from the application config file can be altered within the application itself? If so, how...
1
by: wayne | last post by:
Dear all, may i know how can i delete the contents of an existing file using vc++?? also, i would like to know how can i delete the whole file? thanks alot wayne
4
by: Goran Djuranovic | last post by:
I am trying to COPY, not deploy, ASP.NET application. I know that asp.net application can be copied without any problems by using "Copy Project" menu item, but only if it doesn't have any Crystal...
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
2
by: susinthaa | last post by:
Hi, How to copy an array to a file? I tried the File :: copy, But the array is not copying to the file. @susi=$telnet->cmd("logtail"); $newfile = "$movie/$song/$file"; copy(@susi,$newfile)...
3
by: Barry Erick | last post by:
I guess the express edition does not have this configuration file. I had been using a ini file with getPrivateProfileString, but have not found an example that works in VB 2005 ee , so I looked for...
0
JOHNYKUTTY
by: JOHNYKUTTY | last post by:
Hey, I am developing an application in C#.net, i want to store some settings in application configuration file. iused the followin code ConfigurationSettings.AppSettings.Set("folder",...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.