×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

change centent of xml file under eclipse

change centent of xml file under eclipse

change centent of xml file under eclipse

(OP)
Hi all:

I have just started working on eclipse java in last few weeks in order to create an xml file :

Acutually i have to create three type of xml file not at once each one must have a buttons separatly :

type1 xml file is listed in attachemnt .

I want to do the following :

create three button for each xml type and 13 edittext to enter value in order to update the xml file .

for example :

SET cal : ( 3 edittext)
emaxt : ( 9 edittext)
uname : ( 1 edittext) in exmaple in attachemnt i have added ZLN20 and the other part is fixed :

firt line : X_10"/
second line : X_20"/
third line : X_30"/

I have started with this :



CODE -->

package xml modify;

import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
 
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
 

public class xmlupdate {

	public static void main(String[] args) {
		DocumentBuilderFactory icFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder icBuilder;
        try {
            icBuilder = icFactory.newDocumentBuilder();
            Document doc = icBuilder.newDocument();
        Element mainRootElement = doc.createElementNS("!DOCTYPE MODIFYLMN SYSTEM","MODIFYLMN.dtd");
            doc.appendChild(mainRootElement); 

thanks for your help

RE: change centent of xml file under eclipse

Do you have any particular question?

Cheers,
Dian

RE: change centent of xml file under eclipse

(OP)
Hi:

I want to change some data inside xml file listed in attachemnent as template via JtextField .

SET cal : ( 3 JtextField)
emaxt : ( 9 JtextField)
uname : ( 1 JtextField) in exmaple in attachemnt i have added ZLN20 and the other part is fixed :

firt line : X_10"/
second line : X_20"/
third line : X_30"/

The XML Model created by JDOM or SAX didn't give me what I want for example the first line can't be generated :

<?xml version="1.0" encoding="ISO-8859-1"?>

I have started with this but I can't carry on , is there any other idea ?

CODE -->

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Panel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
 
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class data {

	private JFrame frame;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;
	private JTextField textField_4;
	private JTextField textField_5;
	private JTextField textField_6;
	private JTextField textField_7;
	private JTextField textField_8;
	private JTextField textField_9;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					data window = new data();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public data() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 380, 269);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JButton btnRun = new JButton("Run xml1");
		btnRun.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				DocumentBuilderFactory icFactory = DocumentBuilderFactory.newInstance();
		        DocumentBuilder icBuilder;
		        try {
		            icBuilder = icFactory.newDocumentBuilder();
		            Document doc = icBuilder.newDocument();
		        Element mainRootElement = doc.createElementNS("!DOCTYPE MODIFYLMN SYSTEM","MODIFYLMN.dtd");
		            doc.appendChild(mainRootElement); 
		            Node MODIFYLMN = doc.getElementsByTagName("MODIFYLMN").item(0);
		            NamedNodeMap attr = MODIFYLMN.getAttributes();
					Node nodeAttr = attr.getNamedItem("Format  rev="H"/");
					nodeAttr.setTextContent("");
		        }
		        }
		});
		btnRun.setBounds(185, 30, 89, 23);
		frame.getContentPane().add(btnRun);
		
		textField = new JTextField();
		textField.setBounds(29, 31, 86, 20);
		frame.getContentPane().add(textField);
		textField.setColumns(10);
		
		JLabel lblNewLabel = new JLabel("    uname");
		lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblNewLabel.setBounds(30, 11, 85, 14);
		frame.getContentPane().add(lblNewLabel);
		
		Panel panel = new Panel();
		panel.setBounds(102, 77, 231, 129);
		frame.getContentPane().add(panel);
		panel.setLayout(null);
		
		textField_1 = new JTextField();
		textField_1.setBounds(10, 11, 44, 20);
		panel.add(textField_1);
		textField_1.setColumns(10);
		
		textField_2 = new JTextField();
		textField_2.setBounds(10, 50, 44, 20);
		panel.add(textField_2);
		textField_2.setColumns(10);
		
		textField_3 = new JTextField();
		textField_3.setBounds(10, 99, 44, 20);
		panel.add(textField_3);
		textField_3.setColumns(10);
		
		textField_4 = new JTextField();
		textField_4.setBounds(78, 11, 51, 20);
		panel.add(textField_4);
		textField_4.setColumns(10);
		
		textField_5 = new JTextField();
		textField_5.setBounds(78, 50, 51, 20);
		panel.add(textField_5);
		textField_5.setColumns(10);
		
		textField_6 = new JTextField();
		textField_6.setBounds(78, 99, 51, 20);
		panel.add(textField_6);
		textField_6.setColumns(10);
		
		textField_7 = new JTextField();
		textField_7.setBounds(161, 11, 60, 20);
		panel.add(textField_7);
		textField_7.setColumns(10);
		
		textField_8 = new JTextField();
		textField_8.setBounds(160, 50, 60, 20);
		panel.add(textField_8);
		textField_8.setColumns(10);
		
		textField_9 = new JTextField();
		textField_9.setBounds(162, 99, 55, 20);
		panel.add(textField_9);
		textField_9.setColumns(10);
		
		JLabel lblNewLabel_1 = new JLabel("emaxt_X");
		lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblNewLabel_1.setBounds(10, 81, 74, 14);
		frame.getContentPane().add(lblNewLabel_1);
		
		JLabel lblNewLabel_2 = new JLabel("emaxt_Y");
		lblNewLabel_2.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblNewLabel_2.setBounds(10, 120, 65, 14);
		frame.getContentPane().add(lblNewLabel_2);
		
		JLabel lblNewLabel_3 = new JLabel("emaxt_W");
		lblNewLabel_3.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblNewLabel_3.setBounds(10, 172, 65, 14);
		frame.getContentPane().add(lblNewLabel_3);
	}
	
} 



NB: I put also GUI for my application in attachement

Thanks

RE: change centent of xml file under eclipse

Maybe this helps

Cheers,
Dian

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close