Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa XML again with xml

Have Programming Question? Ask it here!
 
 
 


Antony Devassy
again with xml
2 Answer(s)      6 years ago
Posted in : XML



Advertisement
View Answers

September 10, 2008 at 11:25 AM


hello

Antony

Read this page and related link.

http://www.informit.com/library/content.aspx?b=STY_XML_21days&seqNum=207

Thanks
Rajanikant


September 10, 2008 at 4:58 PM


Hi


import java.io.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

public class ElementNode {
static public void main(String[] arg) {
try{
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a XML file name: ");
String xmlFile = buff.readLine();
File file = new File(xmlFile);
System.out.print("Enter an element which have to delete: ");
String remElement = buff.readLine();
if (file.exists()){
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(xmlFile);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer tFormer = tFactory.newTransformer();
Element element = (Element)doc.getElementsByTagName(remElement).item(0);
// Remove the node
element.getParentNode().removeChild(element);
// Normalize the DOM tree to combine all adjacent nodes
doc.normalize();
Source source = new DOMSource(doc);
Result dest = new StreamResult(System.out);
tFormer.transform(source, dest);
System.out.println();
}
else{
System.out.println("File not found!");
}
}
catch (Exception e){
System.err.println(e);
System.exit(0);
}
}
}

---------------------------------------------

getElementsByTagName(): This getElementsByTagName() method returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.

getChildNodes(): This is a method. This getChildNodes() method returns a NodeList that contains all children of this node.

getParentNode(): The parent of this node. All nodes, except Attr, Document, DocumentFragment, Entity, and Notation may have a parent.

nextSibling(): The node immediately following this node. If there is no such node, this returns null.

------------------------------------

Visit for more information.

http://www.roseindia.net/xml/dom/DOMCloneElements.shtml


Thanks & Regards

Amardeep


Related Tutorials/Questions & Answers:
again with xml - XML
again with xml  hi all i am a beginner in xml so pls give me...)); System.out.print("Enter a XML file name: "); String xmlFile = buff.readLine.../xml/dom/DOMCloneElements.shtml Thanks & Regards Amardeep
There and Back Again
There and Back Again       The weblog of Joshua Eichorn, AJAX, PHP and Open Source Read full Description
Advertisements
again java - Java Beginners
again java  i will ask iam using servlets ,in one program my requirement is if there is a image(if u like) in anywhere and we browse that image and it is store in u r account like orkut. my doubt is if the image is stored
again java - Java Beginners
again java  Hi, i will ask iam using servlets ,in one program my requirement is if there is a image(if u like) in anywhere and we browse that image and it is store in u r account like orkut. my doubt is if the image
java again - Date Calendar
java again  I can't combine your source code yesterday, can you help me again. My problem is how we get result jtextfield2 from if jtexfield1 we enter(jTextfield keypressed) then the result out to jTextfield2, This my jFrame
matching database again - Java Beginners
matching database again  Dear experts, So happy I get through this ask a question page again. Thank God. I want to say "A BIG THANK YOU" for helping me about the matching codes. It is working now after fine tuning
Read data again - Java Beginners
Read data again  sir, i still hav a problem,first your code will be change like this : in netbeans out message error 5. Can you help me again. My database like my question before.Can you fix and find the problem in my code
Read data again - Java Beginners
Read data again  Hey, i want to ask again about how to read data from txt, My DB: kd_div varchar(15), nm_div varchar(30), dep varchar(25), jab varchar(35), cab varchar(15), ket varchar(30) My data in txt file is://i
Hi..Again Doubt .. - Java Beginners
Hi..Again Doubt ..  Thank u for ur Very Good Response...Really great.. i have completed that.. If i click the RadioButton,,ActionListenr should get call. It should add to the MS Acess table..Plz check this out.... hope u ill
doesnt run again - Java Beginners
the soltion   Hi I am sending u again the code, this code run in my
Hi .Again me.. - Java Beginners
Hi .Again me..  Hi Friend...... can u pls send me some code on JPanel.. JPanel shoul have 1pic 1RadioButton .. Like a Voter List... REsponse me..  Hi friend, import java.io.*; import java.awt.
XML
XML  How i remove a tag from xml and update it in my xml
xml
xml  why the content written in xml is more secure
xml
xml  validate student login using xml for library management system
xml
xml  validate student login using xml for library management system
xml
xml  what is name space,xml scema give an example for each   XML Namespaces provide a method to avoid element name conflicts.They are used for providing uniquely named elements and attributes in an XML document
XML
XML  Hi...... Please tel me about that Aren't XML, SGML, and HTML all the same thing? Thanks
XML
XML  please tell me how i remove one tag out of all similar type of tags in xml
xml
xml  how can i remove white space and next line when i copy stream to xml file
XML
XML  create flat file with 20 records. Read the records using xml parser and show required details
xml
xml  what is xml   Extensible Markup Language (XML... that is both human-readable and machine-readable. It is defined in the XML 1.0... gratis open standards. The design goals of XML emphasize simplicity, generality
XML
XML  Design an XML to maintain book details to do the following: (i) Separate Data (ii) Exchange Data (iii) Store Data (iv) Create new language
xml
xml  Design an XML to maintain book details to do the following: (i) Separate Data (ii) Exchange Data (iii) Store Data (iv) Create new language
XML - XML
XML  What is specific definatio of XML? Tell us about marits and demarits of XML? use of XML? How we can use of XML?  Hi, XML... language much like HTML used to describe data. In XML, tags are not predefined
XML - XML
XML XSD validation in java  Can anyone help in writing validation for XML XSD in Java
XML - XML
XML  How to run XML program?  Hi Friend, Please visit the following links: http://www.roseindia.net/xml/ http://www.roseindia.net/xml/dom/ Hope that it will be helpful for you. Thanks
Drop Down Reloads again in IE..How to prevent this?
Drop Down Reloads again in IE..How to prevent this?  Hi i was using two drop down box..One for Displaying date followed by another for Dispalying Month..If i Select/Change Month from the 2nd drop down then the 1st drop down
XML - XML
XML  How to convert database to XML file?   Hi Friend, Do you want to store database data into xml file ? Please clarify this. Thanks
xml - XML
xml  how to match to xml file?can you give example with java code
xml - XML
friend, XPath : It is a language for finding information in an XML document. It is used to navigate through elements and attributes in an XML document. It is a language for selecting nodes from an XML document. It is used
help again plz sorry - Java Beginners
help again plz sorry  Thanks for giving me thread code but i have a question this code is comletelly right and i want to make it runs much faster for that i made 5 threads but 2 things i dont understand 1- with one
xml - XML
xml  define parser and xml,in jaxp api how to up load parsers... then the program contains syntax errors. XML is defined as an extensible... information,Examples and Tutorials on Xml visit to : http
xml - XML
xml  hi convert xml document to xml string.i am using below code... = stw.toString(); after i am getting xml string result, like Successxxx profile... Friend, Please visit the following link: http://www.roseindia.net/xml/reading
xml - XML
xml  hi convert xml file to xml string in java ,after getting the xml string result and how to load xml string result? this my problem pls help..."); FileOutputStream output = new FileOutputStream("new.xml"); ReadXML xml = new
XML - XML
XML  Write a program using SAX that will count the number of occurrences of each element type in an XML document and display them. The document file...)); System.out.print("Enter XML file name:"); String xmlFile = bf.readLine
Consolidated XML to individual XML - XML
Consolidated XML to individual XML  How to separate the consolidated XML file to separate the individual XML names, when a user import the consolidated XML file
Script on the page used too much memory. Reload to enable script again.
Script on the page used too much memory. Reload to enable script again. ... to enable script again". After getting this error other pages also not working. Logout and login again not working. if open the new tab then only working other
the last data entered into database is getting stored again after refreshing
the last data entered into database is getting stored again after refreshing  hey all i made a shout box using php and mysql but the last data entered into the DB is getting retrieved again as i refresh the page.. even
Java XStream
; XStream is a simple library used to serialize the objects to XML and back again.... It provides clean and consistent XML. With XStream it requires no modifications to objects. XStream allows to integrate with other XML APIs very easily
submitting corect user and passowrd, it again comes on login.jsp - Struts
submitting corect user and passowrd, it again comes on login.jsp  i am submit username and password in login.jsp, after submit correct username and password, it again come in login.jsp. Here some files: Struts.xml
Creating XMl file - XML
Creating XMl file   I went on this page: http://www.roseindia.net/xml/dom/createblankdomdocument.shtml and it shows me how to create an XML file, however there is something I don't understand. I have to create an XML file
XML in database - XML
XML in database  Hi Deepak, i m again facing problem with single element multiple tag in xml. i m trying to read the tag values into my... this xml into my db(which is in mysql) i write the following code. import
xml code - XML
xml code  I Read xml is used to store and transfer data can you explain it with sample code
xml certification dumps - XML
xml certification dumps  hi need information. xml certification purpose dumps
web.xml - XML
.. ---- The XML page cannot be displayed Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later
snmp /xml gateway - XML
snmp /xml gateway  hi i would like to develop a snmp management application based on xml for that i need to construct a snmp/xml gateway which translates the xml queries into snmp command and inturn translates the returned
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration form  I AM ENTERING THE DETAILS OFTER IT DISPLAY THE ERROR PLEASE RESEND THE CODE org.apache.jasper.JasperException: java.lang.NumberFormatException
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration form  I AM ENTERING THE DETAILS OFTER IT DISPLAY THE ERROR PLEASE RESEND THE CODE org.apache.jasper.JasperException: java.lang.NumberFormatException
Advertisements
 

 

 

DMCA.com