[jdom-interest] RE: Getting xml header for every input into xml file
Mukunda
hsmukunda at walla.com
Thu Oct 26 22:15:40 PDT 2006
Edelson, Justin wrote:
>
> Do you mean the XML declaration (see
> http://www.w3.org/TR/2000/REC-xml-20001006#sec-prolog-dtd)?
>
> If so, then you can omit this by using the org.jdom.output.Format object
> (http://jdom.org/docs/apidocs/org/jdom/output/Format.html) like:
> Format format = Format.getRawFormat();
> format.setOmitDeclaration(true);
> // any other format modifications
>
> XMLOutputter xmlout = new XMLOutputter(format);
>
>
> I should warn you that your code below, even with this modification,
> will not produce a valid XML document as it will have multiple root
> elements. I can't say whether or not this is a problem for you.
>
> Justin
>
>>-----Original Message-----
>>From: jdom-interest-bounces at jdom.org
>>[mailto:jdom-interest-bounces at jdom.org] On Behalf Of Mukunda
>>Sent: Thursday, October 26, 2006 12:08 AM
>>To: jdom-interest at jdom.org
>>Subject: [jdom-interest] Getting xml header for every input
>>into xml file
>>
>>
>> Hi
>> I am new to JDOM and I am getting xml headers for every
>>input into
>>xml file. I am inputting name and age into xml file through
>>java swings.
>>Below is the code that writes the data into xml file, I tried
>>many ways, but
>>still getting xml headers for every input and
>>could you also please tell me how to check duplicate data
>>while entering
>>data into xml document. thanks.
>>
>>
>>
>>
>> Element ele= new Element("root");
>> Element name=new Element(jLabel1.getText().trim());
>> Element age= new Element(jLabel2.getText().trim());
>> ele.addContent(name);
>> ele.addContent(s1);
>> ele.addContent(age);
>> ele.addContent(s2);
>> Document doc=new Document(ele);
>> FileOutputStream fout = new
>>FileOutputStream("nameage.xml", true);
>> XMLOutputter xmlout = new XMLOutputter();
>> xmlout.output(doc,fout);
>> fout.flush();
>>--
>>View this message in context:
>>http://www.nabble.com/Getting-xml-header-for-every-input-into-x
>>ml-file-tf2511764.html#a7004892
>>Sent from the JDOM - General mailing list archive at Nabble.com.
>>
>>_______________________________________________
>>To control your jdom-interest membership:
>>http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
>>
>
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
>
>
I got your point but it wont print xml header at all,
the problem is xml version is printed for every entry in the xml file as
shown below.
<?xml version="1.0" encoding="UTF-8"?>
<root><name>Mukunda</name><age>26</age></root>
<?xml version="1.0" encoding="UTF-8"?>
<root><name>a</name><age>30</age></root>
I dont want to print version headers to each and every input.
thanks.
--
View this message in context: http://www.nabble.com/Getting-xml-header-for-every-input-into-xml-file-tf2511764.html#a7024711
Sent from the JDOM - General mailing list archive at Nabble.com.
More information about the jdom-interest
mailing list