2017-10-29 15 views
1

기본적으로 XML에 복수 <video_preprocessors> & </video_preprocessors>이 있습니다. 첫 번째 </video_preprocessors> 노드와 두 번째 <video_preprocessors> 노드를 삭제하려면 어떻게해야합니까? <timecode_burnin>XML Starlet 커스텀 XMl 노드 삭제

이 여기에 전체 XML 전에

</video_preprocessors> 
     <video_preprocessors> 
     <timecode_burnin> 
      <font_size>16</font_size> 
      <position>top_center</position> 
      <prefix/> 
     </timecode_burnin> 

그것은 위치했다.

https://pastebin.com/sM7saneG

나는

<timecode_burnin> 매우 감사 전에 </video_preprocessors> <video_preprocessors>을 삭제합니다.

1) 이전 형제 노드 video_preprocessors

2timecode_burnin 노드를 이동)을 삭제 : 당신의 예상 출력/결과를 분석

+0

@jojo, 당신은'삭제할 수 없습니다를 '노드를 삭제하지 않고'timecode_burnin' -이 경우'timecode_burnin '은''노드의 자식 노드이기 때문에 – RomanPerekhrest

답변

0

나는이 작업을 필요로한다는 결론에 왔어요 처음 timecode_burnin 노드

xmlstarlet ed -m "//video_preprocessors/timecode_burnin" \ 
"//video_preprocessors/timecode_burnin/../preceding-sibling::video_preprocessors" \ 
-d "//video_preprocessors[timecode_burnin]/following-sibling::video_preprocessors" test.xml 
을 포함 "이전" video_preprocessors 노드3210

위의 명령은 예상되는 결과를 출력합니다. 처리 후

결정적인 조각 :

... 
<codec>h.264</codec> 
     <video_preprocessors> 
     <deinterlacer> 
      <algorithm>interpolate</algorithm> 
      <deinterlace_mode>Deinterlace</deinterlace_mode> 
      <force>false</force> 
     </deinterlacer> 
     <timecode_burnin> 
      <font_size>16</font_size> 
      <position>top_center</position> 
      <prefix/> 
     </timecode_burnin> 
     </video_preprocessors> 
    </video_description>  
... 

인플레 이스 파일을 수정하려면 - 글로벌 -L 옵션 추가 :
xmlstarlet ed -L -m ...