需要在XML字符串中复制标签

时间:2019-05-21 01:04:51

标签: xml

我有一个每天需要修改的xml文件。为bash或xmlstarlet写的非常简单的东西.....或任何简单的东西。下面的字符串只是需要更改的千个通道之一。因此,它必须解析每一行并将site_id复制到xmltv_id。谢谢您的帮助。

它创建了这个。.

1 import numpy as np 2 3 class State: 4 state = np.zeros(8) 5 fitness=0 6 normalizedFitness=0 7 8 def __init__(self, state): 9 self.state = state 10 self.fitness = hash(self) 11 12 #the hash is used to find the fitness 13 #the fitness is defined by the number of non attacking queens 14 def __hash__(self): 15 count = 0 16 attackingQueens = [False,False,False,False,False,False,False,False] 17 for i in range(0,7): 18 x1 = i+1 19 y1 = self.state[i] 20 for j in range(i+1,8): 21 x2 = j+1 22 y2 = self.state[j] 23 if y1==y2 or abs((x1-x2))==abs((y1-y2)): 24 attackingQueens[i]=True 25 attackingQueens[j]=True 26 for attacking in attackingQueens: 27 if not attacking: 28 count+=1 29 self.fitness=count 30 return count

我需要将site_id值复制到xmltv_id值。

channel update="i" site="merge-xmltv" site_id="citytoronto.ca" xmltv_id="CITY TV (Toronto ON) (CAN)">CITY TV (Toronto ON) (CAN)

1 个答案:

答案 0 :(得分:0)

这有效

sed -i 's/site_id="([^"])" xmltv_id="[^"]"/site_id="\1" xmltv_id="\1"/g' WebGrab++.config.xml