Creating an XML File
I'm using this code to build an XML file and to write it on a file:
DBConnect(); //connection to an Access DB
StringBuffer sql = new StringBuffer();
sql.append("SELECT * FROM atleti ORDER BY id");
try{
rs = st.executeQuery(sql.toString());
Document doc = XMLTool.parse("myXMLFile.xml");
NodeList nl = doc.getElementsByTagName("giocatori");
Node node = nl.item(0);
//Node root = doc.createElement("giocatori");
while(rs.next()){
Node n = doc.createElement("giocatore");
Node n2 = doc.createElement("id");
Node t2 = doc.createTextNode(rs.getString("id"));
n2.appendChild(t2);
n.appendChild(n2);
Node n4 = doc.createElement("cognome");
Node t4 = doc.createTextNode(rs.getString("cognome"));
n4.appendChild(t4);
n.appendChild(n4);
Node n3 = doc.createElement("nome");
Node t3 = doc.createTextNode(rs.getString("Nome"));
n3.appendChild(t3);
n.appendChild(n3);
Node n5 = doc.createElement("codicefiscale");
Node t5 = doc.createTextNode(rs.getString("codicefiscale"));
n5.appendChild(t5);
n.appendChild(n5);
Node n6 = doc.createElement("tesserasanitaria");
Node t6 = doc.createTextNode(rs.getString("tesserasanitaria"));
n6.appendChild(t6);
n.appendChild(n6);
Node n7 = doc.createElement("cartaidentita");
Node t7 = doc.createTextNode(rs.getString("cartaidentita"));
n7.appendChild(t7);
n.appendChild(n7);
Node n8 = doc.createElement("luogonascita");
Node t8 = doc.createTextNode(rs.getString("luogonascita"));
n8.appendChild(t8);
n.appendChild(n8);
Node n9 = doc.createElement("datanascita");
Node t9 = doc.createTextNode(rs.getString("datanascita").substring(0,10));
n9.appendChild(t9);
n.appendChild(n9);
Node n10 = doc.createElement("indirizzo");
Node n11 = doc.createElement("residente");
Node t11 = doc.createTextNode(rs.getString("residente"));
n11.appendChild(t11);
n10.appendChild(n11);
Node n12 = doc.createElement("via");
Node t12 = doc.createTextNode(rs.getString("indirizzo"));
n12.appendChild(t12);
n10.appendChild(n12);
Node n13 = doc.createElement("cap");
Node t13 = doc.createTextNode(rs.getString("cap"));
n13.appendChild(t13);
n10.appendChild(n13);
n.appendChild(n10);
Node n14 = doc.createElement("telefono");
Node n16 = doc.createElement("fisso");
Node t16 = doc.createTextNode(rs.getString("telefonofisso"));
n16.appendChild(t16);
n14.appendChild(n16);
Node n15 = doc.createElement("cellulare");
Node t15 = doc.createTextNode(rs.getString("telefonocellulare"));
n15.appendChild(t15);
n14.appendChild(n15);
n.appendChild(n14);
Node n17 = doc.createElement("email");
Node t17 = doc.createTextNode(rs.getString("email"));
n17.appendChild(t17);
n.appendChild(n17);
Node n18 = doc.createElement("squadra");
Node n19 = doc.createElement("categoria");
Node t19 = doc.createTextNode(" ");
n19.appendChild(t19);
n18.appendChild(n19);
Node n20 = doc.createElement("numero");
Node t20 = doc.createTextNode("0");
n20.appendChild(t20);
n18.appendChild(n20);
n.appendChild(n18);
node.appendChild(n);
//node.normalize();
//System.out.println(node);
FileWriter fw = new FileWriter("OutputFile.xml");
fw.write(node.toString());
fw.flush();
fw.close();I have 2 problems:
a) The output file is writed all on one line and I would like to have it indented so it will be more readable and "cool".
b) I have this error "null Text data??" and I don't know its mind!
Could anybody help me?
hi,
for a commercial grade app , u should rather
have a reusable method.
public static void createXfile(Document doc, String filePath)
FileOutputStream fos =null;
try{
File f = new File(filePath);
OutputFormat of = new OutputFormat("XML","ISO-8859-1",true);
of.setIndent(1);
of.setIndenting(true);
fos = new FileOutputStream(f);
XMLSerializer printer = new XMLSerializer(fos, of);
printer.asDOMSerializer();
printer.serialize(doc);
fos.close();
catch(Exception e){
//u wont reach this place until u messup something
// real bad
Logger.log("XUtil----------"+e.getMessage(), Logger.ERROR);
dont go for transformer just for printing DOM.
HTH
vasanth-ct
Similar Messages
-
Creating an xml file from abap code
Hello All,
Please let me know which FM do I need to execute in order to create an XML file from my ABAP code ?
Thanks in advance,
Paul.This has been discussed before
XML files from ABAP programs -
Need help Take out the null values from the ResultSet and Create a XML file
hi,
I wrote something which connects to Database and gets the ResultSet. From that ResultSet I am creating
a XML file. IN my program these are the main two classes Frame1 and ResultSetToXML. ResultSetToXML which
takes ResultSet & Boolean value in its constructor. I am passing the ResultSet and Boolean value
from Frame1 class. I am passing the boolean value to get the null values from the ResultSet and then add those
null values to XML File. When i run the program it works alright and adds the null and not null values to
the file. But when i pass the boolean value to take out the null values it would not take it out and adds
the null and not null values.
Please look at the code i am posing. I am showing step by step where its not adding the null values.
Any help is always appreciated.
Thanks in advance.
============================================================================
Frame1 Class
============
public class Frame1 extends JFrame{
private JPanel contentPane;
private XQuery xQuery1 = new XQuery();
private XYLayout xYLayout1 = new XYLayout();
public Document doc;
private JButton jButton2 = new JButton();
private Connection con;
private Statement stmt;
private ResultSetToXML rstx;
//Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
//Component initialization
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
xQuery1.setSql("");
xQuery1.setUrl("jdbc:odbc:SCANODBC");
xQuery1.setUserName("SYSDBA");
xQuery1.setPassword("masterkey");
xQuery1.setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
xQuery1.setSql("Select * from Pinfo where pid=2 or pid=4");
jButton2.setText("Get XML from DB");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
catch(java.lang.ClassNotFoundException ex) {
System.err.print("ClassNotFoundException: ");
System.err.println(ex.getMessage());
try {
con = DriverManager.getConnection("jdbc:odbc:SCANODBC","SYSDBA", "masterkey");
stmt = con.createStatement();
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton2_actionPerformed(e);
contentPane.add(jButton2, new XYConstraints(126, 113, -1, -1));
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
void jButton2_actionPerformed(ActionEvent e) {
try{
OutputStream out;
XMLOutputter outputter;
Element root;
org.jdom.Document doc;
root = new Element("PINFO");
String query = "SELECT * FROM PINFO WHERE PID=2 OR PID=4";
ResultSet rs = stmt.executeQuery(query);
/*===========This is where i am passing the ResultSet and boolean=======
===========value to either add the null or not null values in the file======*/
rstx = new ResultSetToXML(rs,true);
} //end of try
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
======================================================================================
ResultSetToXML class
====================
public class ResultSetToXML {
private OutputStream out;
private Element root;
private XMLOutputter outputter;
private Document doc;
// Constructor
public ResultSetToXML(ResultSet rs, boolean checkifnull){
try{
String tagname="";
String tagvalue="";
root = new Element("pinfo");
while (rs.next()){
Element users = new Element("Record");
for(int i=1;i<=rs.getMetaData().getColumnCount(); ++i){
tagname= rs.getMetaData().getColumnName(i);
tagvalue=rs.getString(i);
System.out.println(tagname);
System.out.println(tagvalue);
/*============if the boolean value is false it adds the null and not
null value to the file =====================*/
/*============else it checks if the value is null or the length is
less than 0 and does the else clause in the if(checkifnull)===*/
if(checkifnull){
if((tagvalue == null) || tagvalue.length() < 0 ){
users.addContent((new Element(tagname).setText(tagvalue)));
else{
users.addContent((new Element(tagname).setText(tagvalue)));
else{
users.addContent((new Element(tagname).setText(tagvalue)));
root.addContent(users);
out=new FileOutputStream("c:/XMLFile.xml");
doc = new Document(root);
outputter = new XMLOutputter();
outputter.output(doc,out);
catch(IOException ioe){
System.out.println(ioe);
catch(SQLException sqle){Can someone please help me with this problem
Thanks. -
How to make a bean create an xml file..
How does one create an xml file from a bean?
If anyone have the answer, or some sample code I would really apprecciate it!!!
In advance thanx a lot!!!just "wrap" this up in a bean.
import java.io.*;
import org.jdom.*;
import org.jdom.output.*;
/** Make up and write an XML document, using JDOM
* @author Ian Darwin, [email protected]
* @version $Id: DocWriteJDOM.java,v 1.2 2001/11/21 23:08:17 ian Exp $
public class DocWriteJDOM {
public static void main(String[] av) throws Exception {
DocWriteJDOM dw = new DocWriteJDOM();
Document doc = dw.makeDoc();
// Create an output formatter, and have it write the doc.
new XMLOutputter().output(doc, System.out);
/** Generate the XML document */
protected Document makeDoc() throws Exception {
Document doc = new Document(new Element("Poem"));
doc.getRootElement().
addContent(new Element("Stanza").
addContent(new Element("Line").
setText("Once, upon a midnight dreary")).
addContent(new Element("Line").
setText("While I pondered, weak and weary")));
return doc; -
URGENT -- Perofrmance issue while creating Huge XML file
All XML Experts Please Help....Thanks a lot in Advance
We are trying to create a XML file for a huge table.. 5 million rows and the performance is ver very bad.. Can some body help by giving me an idea what what my best approch could be... or what am I doing wrong in in the code below
CREATE OR REPLACE PROCEDURE Sales_1_Generate_Xml IS
temp_clob CLOB;
temp_buffer VARCHAR2(1);
amount BINARY_INTEGER := 1;
position INTEGER := 1;
filehandle utl_file.file_type;
error_number NUMBER;
error_message VARCHAR2(100);
length_count INTEGER;
qryctx dbms_xmlgen.ctxhandle;
BEGIN
qryctx := dbms_xmlgen.newcontext('select /* INDEX UF_SALES(UF_SALES_IX16) */
TRANSACTION_NUMBER "Transaction_Number",
TRANSACTION_TYPE_ID "Transaction_Type_ID",
PROCESS_FISCAL_DATE_ID "Process_Fiscal_Date_ID",
INVOICE_FISCAL_DATE_ID "Invoice_Fiscal_Date_ID",
ORDER_FISCAL_DATE_ID "Order_Fiscal_Date_ID",
PROCESS_CALENDAR_DATE_ID "Process_Calendar_Date_ID",
INVOICE_CALENDAR_DATE_ID "Invoice_Calendar_Date_ID",
ORDER_CALENDAR_DATE_ID "Order_Calendar_Date_ID",
CURRENT_TM_ID "Current_TM_ID",
CUSTOMER_ID "Customer_ID",
CUSTOMER_TYPE_ID "Customer_Type_ID",
CUSTOMER_LEVEL_ID "Customer_Level_ID",
ACCOUNT_TYPE_ID "Account_Type_ID",
TRADE_CLASS_ID "Trade_Class_ID",
DISTRIBUTOR_ID "Distributor_ID",
PRODUCT_ID "Product_ID",
ORDERED_PRODUCT_ID "Ordered_Product_ID",
BRAND_TYPE_ID "Brand_Type_ID",
LABEL_TYPE_ID "Label_Type_ID",
BRAND_LABEL_ID "Brand_Label_ID",
PRICED_BY_ID "Priced_By_ID",
SALES_UOM_ID "Sales_UOM_ID",
PURCHASING_UOM_ID "Purchasing_UOM_ID",
PRICING_UOM_ID "Pricing_UOM_ID",
NET_COST "Net_Cost",
NPA_S "NPA_S",
CMA_S "CMA_S",
NOT_S "NOT_S",
TOTAL_NATIONAL_ALLOWANCE_S "Total_National_Allowance_S",
LPA_S "LPA_S",
LMA_S "LMA_S",
LOT_S "LOT_S",
TOTAL_LOCAL_ALLOWANCE_S "Total_Local_Allowance_S",
TOTAL_ALLOWANCES_S "Total_Allowances_S",
LPC "LPC",
LPC_EXTENDED "LPC_Extended",
LPF "LPF",
LPF_EXTENDED "LPF_Extended",
TRUE_COST "True_Cost",
CDE "CDE",
LPP "LPP",
SURCHARGE "Surcharge",
COMBINED_SURCHARGE "Combined_Surcharge",
TOTAL_SURCHARGES "Total_Surcharges",
MARKET_COST "Market_Cost",
INSIDE_PAD "Inside_Pad",
SALES_REP_COST "Sales_Rep_Cost",
SALES_REP_MARGIN "Sales_Rep_Margin",
SALES_PRICE "Sales_Price",
SALES_TRUE_MARGIN "Sales_True_Margin",
NVD "NVD",
LVD "LVD",
NID "NID",
LID "LID",
TOTAL_VD "Total_VD",
TOTAL_ID "Total_ID",
TOTAL_DEVIATIONS "Total_Deviations",
GP1 "GP1",
GP2 "GP2",
DEVIATED_COST "Deviated_Cost",
ACTUAL_COST "Actual_Cost",
SALES_TAX "Sales_Tax",
QUANTITY_ORDERED "Quantity_Ordered",
QUANTITY_SHIPPED "Quantity_Shipped",
QUANTITY_DEVIATED "Quantity_Deviated",
QUANTITY_SUBBED "Quantity_Subbed",
UNITS_ORDERED "Units_Ordered",
EACHES_ORDERED "Eaches_Ordered",
EACH_CONVERSION_FACTOR "Each_Conversion_Factor",
UNITS_SHIPPED "Units_Shipped",
EACHES_SHIPPED "Eaches_Shipped",
SHIP_WEIGHT "Ship_Weight",
ACTUAL_GP_DLR "Actual_GP_Dlr",
TRUE_GP_DLR "True_GP_Dlr",
LANDED_GP_DLR "Landed_GP_Dlr",
LANDED_ACTUAL_GP_DLR "Landed_Actual_GP_Dlr",
INVOICE_GP_DLR "Invoice_GP_Dlr",
INVOICE_ACTUAL_GP_DLR "Invoice_Actual_GP_Dlr",
ADJUSTED_ACTUAL_GP_DLR "Adjusted_Actual_GP_Dlr",
EB_S "EB_S",
MB_S "MB_S",
ACTUAL_TM_ID "Actual_TM_ID",
ACTUAL_TM_NAME "Actual_TM_Name",
ACTUAL_DSM_ID "Actual_DSM_ID",
ACTUAL_DSM_NAME "Actual_DSM_Name",
INVOICE_NUMBER "Invoice_Number ",
CONTRACT_NUMBER "Contract_Number",
CUSTOMER_NUMBER "Customer_Number",
CUSTOMER "Customer",
PRODUCT_NUMBER "Product_Number",
MASTER_DISTRIBUTOR_ID "Master_Distributor_ID",
ORDERED_PRODUCT_NUMBER "Ordered_Product_Number",
NATIVE_PRODUCT_STATUS "Native_Product_Status",
NATIVE_PRICED_BY_INDICATOR "Native_Priced_By_Indicator",
EXTRACTION_TIME "Extraction_Time"
from uf_sales where distributor_id in (''5139'',
''5140'',
''5145'',
''5150'',
''5160'',
''5175'',
''5180'',
''5210'',
''5220'',
''5230'')
DBMS_XMLGen.setRowTag(qryctx,'Sales_Record');
DBMS_XMLGen.setRowSetTag(qryctx,'Sales_Set');
temp_clob:=dbms_xmlgen.getxml(qryctx);
length_count := dbms_lob.getlength(temp_clob);
dbms_output.put_line('Internal LOB size is: ' || length_count);
filehandle := utl_file.fopen('DATA_EXTRACT','Sales_1.xml','Wb',32767);
WHILE length_count <> 0 LOOP
dbms_lob.read (temp_clob, amount, position, temp_buffer);
--utl_file.put (filehandle, temp_buffer);
utl_file.put_raw(filehandle, utl_raw.cast_to_raw(temp_buffer));
position := position + 1;
length_count := length_count - 1;
temp_buffer := null;
END LOOP;
dbms_output.put_line('Exit the loop');
utl_file.fclose(filehandle);
DBMS_XMLGen.closeContext(qryctx);
dbms_output.put_line('Close the file');
EXCEPTION
WHEN OTHERS THEN
BEGIN
error_number := sqlcode;
error_message := substr(sqlerrm ,1 ,100);
dbms_output.put_line('Error #: ' || error_number);
dbms_output.put_line('Error Message: ' || error_message);
utl_file.fclose_all;
END;
END;
/OK, so you are writing the file with UTL_FILE. How long is the whole process taking. Have you timed the time taken to generate the temp_clob with the result Vs the time to write the output to a file.
-
Creating an xml file from recordset
Hi...
XML newbie here - so.
Is it possible to create and xml file from a recordset?
I need to create a datafeed of our e-commerce products.
Also, some of the db data contains HTML Code (product
description field),
how will this effect the xml file?
Another problem is that my xml file needs to contain url's
for the products
and product images. My ASP pages contain these URL in hard
code and then
pull the actual file names from the db
Hope that makes some sense
Thanks for any help
AndyHi David
Thanks for your help.
I think it will have to be option 1 as i am using Access DB.
I don't know how to go about it but will serach good old
Google.
Here is my recordset below, that pulls the required data from
Access.
The product and product image URL's need to be in the xml
file but only the
product image name and product id are in the database, e.g
image name
(imagename.jpg) productid (21)
The actual URL's are hardcoded in my ASP pages, e.g <img
src="products/medium/<%=(RSDetails.Fields.Item("Image").Value)%>"
Not sure if this makes things any clearer :-|
Thanks Again
Andy
<%
Dim RSdatafeed
Dim RSdatafeed_numRows
Set RSdatafeed = Server.CreateObject("ADODB.Recordset")
RSdatafeed.ActiveConnection = MM_shoppingcart_STRING
RSdatafeed.Source = "SELECT Products.Product,
Products.Description,
Products.Image, Products.image2, Products.ListPrice,
Products.Price,
Products.xml_feed, Manufacturers.Manufacturer,
Shipping.ShippingCost FROM
Shipping, Products INNER JOIN Manufacturers ON
Products.ManufacturerID =
Manufacturers.ManufacturerID WHERE
(((Products.xml_feed)=No));"
RSdatafeed.CursorType = 0
RSdatafeed.CursorLocation = 2
RSdatafeed.LockType = 1
RSdatafeed.Open()
RSdatafeed_numRows = 0
%>
"DEPearson" <[email protected]> wrote in
message
news:[email protected]...
> Andy,
>
> There are two ways you can create a xml file from a
recordset
>
> 1. Is to code it using Server.CreateObject(XMLDOM)
> 2. If you are using SQL server 2005, just request the RS
returns as XML
> data. using FOR XML AUTO after the where cause ( the
best way with 2005
> and
> higher sql server)
>
> The db data containing HTML code should not effect your
xml file, unless
> it
> is bad markup. You could wrap the data with
<![CDATA[the data or html
> markup, or javascript]]>
>
> If the url is a recordset field, then it will return
with the xml data.
> If
> not you can create a storage procedure that will build
your URL from the
> data
> in the database.
>
> It is best to use storage procedure (SP )for security
reason when pulling
> data
> from a MS Sql server, make all calls to the database in
a SP. Also be sure
> to
> validate the values in the querystrings before accepting
them, check for
> hack
> code.
>
> David
> -
Create a xml file from an internal table: CALL TRANSFORMATION
Hello gurus,
I want to create a xml file using data from scustom table. I will create an internal table and will select some records to it.
I searched the forum and i discovered the call transformation, but when i execute the example program at the CALL TRANSFORMATION shows a dump screen.
How we create a xml file from internal table??
Please help me. I will mark the useful answers.I'm using if_ixml class to create xml documents
TYPES: BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
DATA: o_ixml TYPE REF TO if_ixml,
o_document TYPE REF TO if_ixml_document,
o_element TYPE REF TO if_ixml_element,
o_streamfactory TYPE REF TO if_ixml_stream_factory,
o_ostream TYPE REF TO if_ixml_ostream,
o_renderer TYPE REF TO if_ixml_renderer.
DATA: t_xml_table TYPE TABLE OF xml_line,
v_xml_size TYPE i.
o_ixml = cl_ixml=>create( ).
o_document = o_ixml->create_document( ).
* The o_document have a set of methods to add elements, attributes, etc.
o_element = o_document->create_simple_element(
name = 'RootNode'
value = 'some text'
parent = o_document ).
o_streamfactory = o_ixml->create_stream_factory( ).
o_ostream = o_streamfactory->create_ostream_itable( table = t_xml_table ).
o_renderer = o_ixml->create_renderer( ostream = o_ostream document = o_document ).
o_renderer->render( ).
v_xml_size = o_ostream->get_num_written_raw( ).
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = v_xml_size
filename = 'C:a.xml'
filetype = 'BIN'
CHANGING
data_tab = t_xml_table. -
How I can create a XML file from java Aplication
How I can create a XML file from java Aplication
whith have a the following structure
<users>
<user>
<login>anyName</login>
<password>xxxx</password>
</user>
</users>
the password label must be encripted
accept any suggestionLet us assume you have all the data from the jsp form in an java bean object..
Now you want a xml file. This can be acheived in 2 ways
1. Write it into a file using java.io classes. Say you have a class with name
write("<name>"+obj.getName+</name>);
bingo you have a flat file with the xml
2. Use data binding to do the trick
will recommend JiBx and Castor for the 2nd option
Regards,
Rajagopal -
Creating an xml file from java.
I trying to create an xml file using a java program. I just wondering what is the best way to go about it and what should i use jdom ,xerces sax etc.
Use JAXP+SAX.
Here an example:import java.io.*;
// SAX classes.
import org.xml.sax.*;
import org.xml.sax.helpers.*;
//JAXP 1.1
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.sax.*;
// PrintWriter from a Servlet
PrintWriter out = response.getWriter();
StreamResult streamResult = new StreamResult(out);
SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
// SAX2.0 ContentHandler.
TransformerHandler hd = tf.newTransformerHandler();
Transformer serializer = hd.getTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"users.dtd");
serializer.setOutputProperty(OutputKeys.INDENT,"yes");
hd.setResult(streamResult);
hd.startDocument();
AttributesImpl atts = new AttributesImpl();
// USERS tag.
hd.startElement("","","USERS",atts);
// USER tags.
String[] id = {"PWD122","MX787","A4Q45"};
String[] type = {"customer","manager","employee"};
String[] desc = {"Tim@Home","Jack&Moud","John D'o�"};
for (int i=0;i<id.length;i++)
atts.clear();
atts.addAttribute("","","ID","CDATA",id);
atts.addAttribute("","","TYPE","CDATA",type[i]);
hd.startElement("","","USER",atts);
hd.characters(desc[i].toCharArray(),0,desc[i].length());
hd.endElement("","","USER");
hd.endElement("","","USERS");
hd.endDocument();
[i]This xml generation program might be the best solution because it uses JAXP 1.1 so it will work under JDK 1.4 or JDK 1.2/1.3 with XALAN2 library (or any XML library JAXP 1.1 compliant). It's also memory-friendly because it doesn't need DOM.
See http://www.javazoom.net/services/newsletter/xmlgeneration.html
Hope That Helps -
I'm a new user of XML. I've a very important question:
Is it possible create an XML file using some java package? If yes what package i must use? JDOM is the right product?
ThanksYes, JDOM is the right choice for 99% of your work.
DOM is too difficult to use.
That is the reason why JDOM has been developped. -
How to create an XML file from scratch ?
Hi all,
I'm afraid that I will seem dummy, but I think I really misunderstand something or I'm trying to do something that is not possible...
I would like to create a XML file containing the following:<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="pl.xsl"?>
<!DOCTYPE playlist SYSTEM "pl.dtd">
<playlist id="2">
</playlist>I really need to have both the stylesheet and the DOCTYPE declarations... Does anyone know if this is possible ?
To create the XML Document, I am using the DocumentBuilder object from javax.xml package (jaxp-1.2-ea2). I think this, at least, is correct.
To print out the XML document I have tried to use :
- the Transformer from javax.xml package (jaxp-1.2-ea2) but I could obtain only the DOCTYPE declaration.
- the Serializer from Xerces parser (version 2.0.1) to print out the Document I am creating with the jaxp, but I was able only to obtain the stylesheet declaration...
So far I have just understand that there is a difference between Serializer and Transformer (one is serializing, and the other is transforming ;-)), but I couldn't figure out which one would be suitable to produce the XML file above...
I would really appreciate if one could help me with that ;-)
Thanks,
KarauCould send me an example ?
For the moment I am using Transformer in that way:
TransformerFactory tfactory = TransformerFactory.newInstance();
try {
Transformer transformer = tfactory.newTransformer();
DOMSource source = new DOMSource(playlistDoc.getDocumentElement());
StreamResult res = new StreamResult(new File(path));
transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, PL_DTD);
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(source, res);
catch (TransformerConfigurationException tce) {
throw tce;
catch (TransformerException te) {
throw te;
} -
I need to loop through a query to create an xml file. How do
I create a file using CF? I thought maybe cffile but I don't see an
attribute for "new", just things like append, delete, move etc...
Am I missing something here? I've used cfheader to send content to
the browser but just not sure how to create a file and place in on
the server.
Any help would be appreciated GREATLY!!!!See if this helps:
http://tutorial97.easycfm.com/
Ken Ford
Adobe Community Expert - Dreamweaver
Fordwebs, LLC
http://www.fordwebs.com
"cfcolorado" <[email protected]> wrote in
message news:fe3poc$cvf$[email protected]..
>I need to loop through a query to create an xml file. How
do I create a file
> using CF? I thought maybe cffile but I don't see an
attribute for "new", just
> things like append, delete, move etc... Am I missing
something here? I've
> used cfheader to send content to the browser but just
not sure how to create a
> file and place in on the server.
>
> Any help would be appreciated GREATLY!!!!
> -
hi !
i want to create an xml file frim hierarchical data (n depth) . please advise me how to create xml file using dom and how to write dom elements to disk...read the documentation foor DOM it is not hard. You can create root elements, then append children to them, finally you can seralize the DOM Tree you just built
-
Creating an XML file using Java Standalone
Hi,
My problem is -
1) write a java stand alone retrieving data from database and put the data in XML format (i.e; we have to create an XML file).
How to do this? Could any one of you please suggest me how to code or can i have any links that refer the code snippets.
Thanks.Could someone give me a link with information on how SAX is used to create an XML?
null -
Creating an XML file with CFFILE on UNIX server
I've run into a problem with creating an XML file on a UNIX
server. I don't have access to the server and I'm trying to create
an XML file so an outside agency can read it through the site URL.
On a Windows machine I use GetDirectoryFromPath and
ExpandPath to return the drive/path info, then I create the file
with this and the query result. On the Unix web server I am only
being returned a relative path, because of this I can't write the
XML file to the web server. Any idea how to get around this?Knowing as little as I do about Unix I thought you still needed
a drive "letter" to write the XML file to. I've been told I can get
to the root but that it's root is "/bottomFolderName" (I was
expecting R:\webRootPath\yourFolder\etc\XMLFileWrittenHere).
No, that is Windows thinking. You were told right. In Linux,
a path usually begins with the forward slash /.
I had doubts about your code itself. Did you run your version
of my example on Windows? If it works, then you will only have to
replace the Windows path with something like the following. The
rest of the code remains the same. -
Creating an xml file from the Basic java Object
how to create an XML file using the values available in the object with reference to an xsd or dtd file..
(OR )
is it possible to write the contents of an object to an xml file without knowing the dtd or xsd file .......how to create an XML file using the values available in the object with reference to an xsd or dtd file..
(OR )
is it possible to write the contents of an object to an xml file without knowing the dtd or xsd file .......
Maybe you are looking for
-
Export to Word Format BUG - Pages won't do it
The latest version of Pages for MAC (5.0.1), can't export a simple text document to WORD format. It takes forever and, at last, craches my Mac . Anyone else's expericing it? Thanks, Daniel
-
Condition type value to be load on inventory at time of MIGO.
hi, We have made a new condition type for domestic purchases & we require that the same should work like the other condition types of Import (where vendor can be different from the main vendor), we want that the value of the same should be load on in
-
I am arranging a trip for a group of middle school / high school students. I have a sheet that lists the student info and then a box to check that they are confirmed. At that bottom of that column I'd like to have the total of the number of people wh
-
Burned DVD but won't play on Apple or two other DVD players
My kids scratch up original movie DVDs so thought I would make a copy that they could use and keep the original pristine. Copied audio and video folders from movie DVD onto harddrive. New Memorex DVD-RW into Apple and dragged audio and video folders
-
I have a producer / consumer architecture - data are being read (from a TCP read) in the producer loop and placed on a queue. The consumer is reading the queue and doing lots of modelling, analysis and display. This architecture was chosen because th