Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

XML remove tags

Ads

 
 

Share on Google+Share on Google+

Varsha Yadav
XML remove tags
3 Answer(s)      6 years and a month ago
Posted in : Java Beginners

when i remove a tag from xml, it create blank spaces or next line. how i protect it to updae in my xml

Ads
View Answers

August 19, 2013 at 4:45 PM


Hello Varsha,

DOM objects always bahave a emty line when you are going to remove a XML Node.

USE the below option to remove empty line

print("try{
        Scanner scanner = new Scanner(new File(filepath));
        PrintStream out = new PrintStream(new File("outfile.xml"));
        while(scanner.hasNextLine()){
            String line = scanner.nextLine();
            String ol = line;
            line = line.trim();
            if(line.length() > 0)
                out.println(ol);
        }
        out.close();
        scanner.close();
        ret = "Empty lines removed....";
    }catch(Exception e){}");


August 19, 2013 at 4:45 PM


Hello Varsha,

DOM objects always bahave a emty line when you are going to remove a XML Node.

USE the below option to remove empty line

print("try{
        Scanner scanner = new Scanner(new File(filepath));
        PrintStream out = new PrintStream(new File("outfile.xml"));
        while(scanner.hasNextLine()){
            String line = scanner.nextLine();
            String ol = line;
            line = line.trim();
            if(line.length() > 0)
                out.println(ol);
        }
        out.close();
        scanner.close();
        ret = "Empty lines removed....";
    }catch(Exception e){}");


August 19, 2013 at 4:45 PM


Hello Varsha,

DOM objects always bahave a emty line when you are going to remove a XML Node.

USE the below option to remove empty line

print("try{
        Scanner scanner = new Scanner(new File(filepath));
        PrintStream out = new PrintStream(new File("outfile.xml"));
        while(scanner.hasNextLine()){
            String line = scanner.nextLine();
            String ol = line;
            line = line.trim();
            if(line.length() > 0)
                out.println(ol);
        }
        out.close();
        scanner.close();
        ret = "Empty lines removed....";
    }catch(Exception e){}");

Ads









Related Tutorials/Questions & Answers:
XML remove tags
XML remove tags  how i update a tag from xml file
XML remove tags
XML remove tags  when i remove a tag from xml, it create blank spaces or next line. how i protect it to updae in my xml
Advertisements
tags in xml - XML
tags in xml  Can I use : (colon )in xml tag? For ex. Is this valid?  Hi Friend, You can use colon(:) in XML tag.But is not valid. Thanks
Tags in XML - XML
Tags in XML  What are the Tags of XML  In XML there is no predefined tag. Every user can write their own tags at the time of creating it or later. You can define as many tag as you want according to your requirement
Regular Expression for removing XML Tags
Regular Expression for removing XML Tags  Hi, Good Afternoon.I want a Regular expression in java which is removing the XML Tags in the specified... after applying regular expression is only "How are you".Need to remove all XML
i want to remove specific node in xml file
i want to remove specific node in xml file   <A> <B>hi <C>by <A> <B>hellow <C>how r u ? i want to delet node which is == hellow using java program please help me . tanks in advance
Remove Element from XML Document
Remove Element from XML Document       In this section, you will learn to remove any element from a given  XML document. Whenever you remove the xml element from the xml document
Version of commons-jelly-tags-xml>commons-jelly-tags-xml dependency
List of Version of commons-jelly-tags-xml>commons-jelly-tags-xml dependency
how to remove tags in HTML without functionalities? - Java Beginners
how to remove tags in HTML without functionalities?  hi to all, I create an application for converting html to ppt in java. And in this i convert the text from html to ppt and i able to remove the HTML tags from .html code
Artifacts of commons-jelly-tags-xml
List of Artifacts of commons-jelly-tags-xml maven depenency
Use of Core XML tags in JSP
Use of Core XML tags in JSP   ... Tags: Core XML tags provides access to XML data and used to parse these data. There are three tags in this Core XML tag set. 1. <x:out> : This tag
XML
XML  please tell me how i remove one tag out of all similar type of tags in xml
JDOM Element Example, How to remove attribute of xml element in java.
JDOM Element Example, How to remove attribute of xml element in java. In this tutorial, we will see how to remove attribute of xml element in java with the help of JDOM library. It is a java tool kit for xml parsing. With the help
Maven Dependency commons-jelly-tags-xml >> 20040613.030723
You should include the dependency code given in this page to add Maven Dependency of commons-jelly-tags-xml >> commons-jelly-tags-xml version20040613.030723 in your project
Maven Dependency commons-jelly-tags-xml >> 20040902.072037
You should include the dependency code given in this page to add Maven Dependency of commons-jelly-tags-xml >> commons-jelly-tags-xml version20040902.072037 in your project
JSTL XML Tags
JSTL XML Tags No one can have any second opinion about the elegance of xml... and such terms, and it may have been none too easy to learn. But the xml tags... to study them. Making our study even easier, many of the xml tags in JSTL
JDOM Element Example, How to add and remove child from xml file.
JDOM Element Example, How to add and remove child from xml file. In this tutorial, we will see how to add and remove child node in an xml Document tree. We can add child any where in xml document tree with the help of JDOM API
Version of commons-jelly>commons-jelly-tags-xml dependency
List of Version of commons-jelly>commons-jelly-tags-xml dependency
solution to get values for xml namespace tags from sqldatabase in java
solution to get values for xml namespace tags from sqldatabase in java  hi I have written a code in java to get these xml tags < company comp:loc... tags in separate file. please provide me solution to get values for xml tags
Solution to get vaues for xml tags fform sql database in java
Solution to get vaues for xml tags fform sql database in java  hi I have written a code in java to get these xml tags < company comp:loc=" "/>...(" "). how do i get these values.. already connected database and created xml tags
Want solution to get values for xml namespace tags from database in java
Want solution to get values for xml namespace tags from database in java  hi I have written a code in java to get these xml tags < company comp... xml tags in separate file. please provide me solution to get values for xml tags
Maven Dependency commons-jelly-tags-xml >> 1.0
You should include the dependency code given in this page to add Maven Dependency of commons-jelly >> commons-jelly-tags-xml version1.0 in your project
Maven Dependency commons-jelly-tags-xml >> 1.1
You should include the dependency code given in this page to add Maven Dependency of commons-jelly >> commons-jelly-tags-xml version1.1 in your project
Maven Dependency commons-jelly-tags-xml >> 20030211.142705
You should include the dependency code given in this page to add Maven Dependency of commons-jelly >> commons-jelly-tags-xml version20030211.142705 in your project
JDOM Element Example, How to remove child of an element from xml file in java.
JDOM Element Example, How to remove child of an element from xml file in java. In this tutorial, we will see how to remove child of an element from xml file... for manipulating, creating and serializing  xml file. With the help of this java
XML
XML  How i remove a tag from xml and update it in my xml
xml
xml  how can i remove white space and next line when i copy stream to xml file
Need solution to get values for XML namespace tags from SQL database in Java
Need solution to get values for XML namespace tags from SQL database in Java  hi I have written a code in java to get these xml tags < company... and created xml tags in separate file. please provide me solution to get values for xml
JSTL XML Tags
in this tutorial you will learn JSTL XML examples
JSTL XML Tags
JSTL XML Tags       PART-4 - JSTL  &  SQL-TAGS   Tutorial Home | Part 1... on JSTL,the author deals with the 'sql' tags in JSTL  and shows how
Remove history
Remove history  how to remove history in struts2 after clicking on logout link