Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
laxmikant upadhyay
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any Java XMl library can do that: XOM, JDOM, dom4j, ... Their respective web sites have code that demonstrate how to manipulate XML using them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic