  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | RE: Getting xml header for every input into xml file | RE: Getting xml header for every input into xml file 2006-10-27 - By Mukunda
Back
Edelson, Justin wrote: > > Do you mean the XML declaration (see > http://www.w3.org/TR/2000/REC-xml-20001006 (See http://xml-20001006.ora-code.com)#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@(protected) >>[mailto:jdom-interest-bounces@(protected)] On Behalf Of Mukunda >>Sent: Thursday, October 26, 2006 12:08 AM >>To: jdom-interest@(protected) >>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@(protected) >> > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ > To control your jdom-interest membership: > http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected) > >
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 (See http://UTF-8.ora-code.com)"?> <root><name>Mukunda</name><age>26</age></root> <?xml version="1.0" encoding="UTF-8 (See http://UTF-8.ora-code.com)"?> <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.
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
|
|
 |