GeeCON Prague 2014*
The moose likes Java in General and the fly likes how to delete a tag from xml document ?? please help !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "how to delete a tag from xml document ?? please help !!" Watch "how to delete a tag from xml document ?? please help !!" New topic
Author

how to delete a tag from xml document ?? please help !!

laxmikant upadhyay
Greenhorn

Joined: Aug 24, 2012
Posts: 14
hi,
i have a input document as below :

<Layer ID="1" name="Topology">
<Layer ID="1000" name="UPM">
<Information>
<Connection>
<ftp_user>root</ftp_user>
<ftp_password>{3DES}hMoOog68jLw=</ftp_password>
<ftp_security_type>1</ftp_security_type>
<telnet_username>root</telnet_username>
<telnet_password>{3DES}hMoOog68jLw=</telnet_password>
<telnet_security_type>1</telnet_security_type>
</Connection>
<metadata>UPM_MD.xml</metadata>
</Information>
<UnitInstance DataIp="10.45.76.100" Hostname="upm1" ID="100">
<Information>
<Connection>
<ftp_user>root</ftp_user>
<ftp_password>{3DES}hMoOog68jLw=</ftp_password>
<ftp_security_type>1</ftp_security_type>
<telnet_username>root</telnet_username>
<telnet_password>{3DES}hMoOog68jLw=</telnet_password>
<telnet_security_type>1</telnet_security_type>
</Connection>
<metadata>UPM_MD.xml</metadata>
</Information>
</UnitInstance>
<UnitInstance DataIp="10.45.76.100" Hostname="upm1-vip" ID="101">
<Information>
<Connection>
<ftp_user>root</ftp_user>
<ftp_password>{3DES}hMoOog68jLw=</ftp_password>
<ftp_security_type>1</ftp_security_type>
<telnet_username>root</telnet_username>
<telnet_password>{3DES}hMoOog68jLw=</telnet_password>
<telnet_security_type>1</telnet_security_type>
</Connection>
<metadata>UPM_MD.xml</metadata>
</Information>
</UnitInstance>
</Layer>
</Layer>

now i want to remove all ftp tags from the above document and want output document as below:

<Layer ID="1" name="Topology">
<Layer ID="1000" name="UPM">
<Information>
<Connection>

<telnet_username>root</telnet_username>
<telnet_password>{3DES}hMoOog68jLw=</telnet_password>
<telnet_security_type>1</telnet_security_type>
</Connection>
<metadata>UPM_MD.xml</metadata>
</Information>
<UnitInstance DataIp="10.45.76.100" Hostname="upm1" ID="100">
<Information>
<Connection>

<telnet_username>root</telnet_username>
<telnet_password>{3DES}hMoOog68jLw=</telnet_password>
<telnet_security_type>1</telnet_security_type>
</Connection>
<metadata>UPM_MD.xml</metadata>
</Information>
</UnitInstance>
<UnitInstance DataIp="10.45.76.100" Hostname="upm1-vip" ID="101">
<Information>
<Connection>

<telnet_username>root</telnet_username>
<telnet_password>{3DES}hMoOog68jLw=</telnet_password>
<telnet_security_type>1</telnet_security_type>
</Connection>
<metadata>UPM_MD.xml</metadata>
</Information>
</UnitInstance>
</Layer>
</Layer>


can somebody provide me a java code for the same !!!
thanks in advance !!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42022
    
  64
Any Java XMl library can do that: XOM, JDOM, dom4j, ... Their respective web sites have code that demonstrate how to manipulate XML using them.


Ping & DNS - my free Android networking tools app
 
GeeCON Prague 2014
 
subject: how to delete a tag from xml document ?? please help !!