uma prem

Greenhorn
+ Follow
since Jun 21, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by uma prem

Thanks both of you for your valuable suggestion

I now understood the concept there should be only one root.
I changed the below lines and can get the output now as I expect

But i have one more thing to do.
I need to pass the line by line value of the textfile(stored in line of my writeRecord()) to be passed to after "record:id:"
How can i do that.

// identifier.appendChild(doc.createTextNode("record:id:"));
Please advise.


Below is my recent prgram
import java.io.*;
import java.util.Calendar;
import java.util.ArrayList;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

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

public class DeleteXml
{

public static void main(String[] args) throws Exception {
try{
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
doc.setXmlStandalone(true);

Element Identifier=doc.createElement("Identifiers");
doc.appendChild(Identifier);
FileInputStream fis = new FileInputStream("D:\\Output\\del\\ids.txt");
DataInputStream in = new DataInputStream(fis);

BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;

while ((strLine = br.readLine()) != null) {
writeRecord(doc,Identifier,strLine);
System.out.println(strLine);
}

}
catch(ParserConfigurationException pce)
{
pce.printStackTrace();
}
/*catch(TransformerException tfe)
{
tfe.printStackTrace();
}*/
}
public static void writeRecord(Document doc,Element ele,String line)
{
Element rootElement=doc.createElement("record");
ele.appendChild(rootElement);

Element header =doc.createElement("header");
rootElement.appendChild(header);

header.setAttribute("teststatus","active");

Element identifier = doc.createElement("identifier");
identifier.appendChild(doc.createTextNode("record:id:"));

Element datestamp = doc.createElement("Datestamp");
header.appendChild(identifier);
header.appendChild(datestamp);

try {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new File("D:\\testing.xml"));
// transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(source, result);
} catch (Exception e) {
// TODO: handle exception
}
}
}
Hi Ulf Dimetter,


Thanks a lot for your response. So is that i have to create one more root element. Can you please suggest me with some sample.

Hi ,

I am stuck below please help

I need to creat an xml with a specific pattern and I have one text file "ids.txt containging the id(1234,1245,1353,1323,5454,9898,8787, eg 10 lines. Now i have to create my xml tags ten times.

Below is the program which i have tried, when i run the firsttime xml is created but next time i get the error like this

An attempt was made to insert a node where it is not permitted. Some one please help to solve my problem

Thanks a lot for your time

Regards
Thanks Ulf Dittmer

Hi William,

The file size is only max of 8kb per file but have many files(1000files in folder)

I am doing like this first trying to read the file

but error is coming what s the mistake please let me know i have attached my file.

Thanks a lot.

Hi,

I am new to programming, need your kind help :

Currently I have a set of xml files in a folder consisting of single xml per file. I need to insert the below header for each xml. How can i do this
<header>
<identifier>ip:abc:12345</identifier>
<datestamp>datetimestampZ</datestamp>
<setSpec>active</setSpec>
</header>

Please help

Hi Campbell,

Thanks for your reply,

My problem is :

My bidfilename is bid.txt having one value in each line(1000lines together)
Now in my program, I am passing the entire textfile(bid.txt) to the method, instead of one line at a time.I want help in that

fieldname="+@\\:Identifier:\""+text+"\"";
uuid=ABC.GetUIDByField(pathname,fieldname);//

like when I check in the fieldname parameter inside the method GetUIDbyField of class ABC,the fieldname shows +@\\:Identifier:\""+bid.txt(the entire filename) ,instead of +@\\:Identifier:\""+12134(one by one line value at a time)

hope i am clear of the problem facing

Please reply
12 years ago
hi,

i have a text file, having one value in each line digitsandnumbers. now once i read it line by line i need to pass each lines value to one staticmethod (class ABC)which takes it as one of the parameter to get me one more id. Please help me,.i am in trouble.... Please help me with the correct code

what i have done so far is

thanks a lot for your time
12 years ago
Hi Cameron,

As requested , I wish to study SCJA book of 2nd edition written by you. Can you help me with step details for buying.

Regards
Uma
13 years ago
Hi,

I want to read SCJA guide 2nd edition book written by Cameron Mckenzie in Singapore, Is it possible, if yes how if online or available in any shops?? Please reply

Regards
Uma
13 years ago
Hi,

Is there any way to check the correct answers for the last exams we wrote inorder to correct ourself..

Waitng for reply.

Thanks

Uma
13 years ago
Hi,

I had applied for SCJA on June 08 2010 but got only 64% against 68% i am very disappointed, i think i lost marks in composition identification in calling objects and in programs. I want to take it again on July 12 2010.Any guidelines will be much appreciated. Waiting for the response.

Thanks

Uma
13 years ago