Author Topic: Need programming help with XML using the commandline  (Read 788 times)

Offline MBantz

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1317
Need programming help with XML using the commandline
« on: July 05, 2009, 05:15:37 AM »
I have this small xml file that is used in Mythtv - and, say, need to delete the entire button element with the type STREAM. Im using the XMLstarlet to insert elements, but I haven't found the command syntax to delete elements of a certain type.

Code: [Select]
<mythmenu name="LIBRARY">

   <button>
     <type>STREAM</type>
     <text>Play Online Streams</text>
     <text lang="HE">נגן מדיה מכוונת</text>
     <action>PLUGIN mythstream</action>
     <depends>mythstream</depends>
   </button>

   <button>
     <type>IMAGES</type>
     <text>Image Gallery</text>
     <text lang="IT">Immagini</text>
     <text lang="ES">Fotos</text>
     <depends>mythgallery</depends>
   </button>
  
</mythmenu>

to insert elements I insert them line-by-line, can this be done a more elegant way?

Code: [Select]
xml ed -O -i /mythmenu/button[1] -t elem -n button -v "" library.xml | \
 xml ed -O -s /mythmenu/button[1] -t elem -n type -v "STREAM" | \
 xml ed -O -s /mythmenu/button[1] -t elem -n text -v "Myth Vodka" | \
 xml ed -O -s /mythmenu/button[1] -t elem -n action -v "PLUGIN mythvodka" | \
 xml ed -O -s /mythmenu/button[1] -t elem -n depends -v "mythvodka"

thanks,
MBantz
« Last Edit: July 05, 2009, 05:19:33 AM by MBantz »