2012-12-11 3 views
0

XML Starlet을 사용하여 프로그래밍 방식으로 XML 파일을 편집하고 있습니다. 내가 두 번째 <intent-filter> 노드에 새 <action> 태그를 추가하기 위해 노력하고있어2 개의 동일한 노드로 구성된 두 번째 노드에 XML 노드를 삽입하십시오.

<manifest> 
      <application> 
        <activity> 
          <intent-filter> 
            <action/> 
            <category/> 
          </intent-filter> 
          <intent-filter> 
          </intent-filter> 
        </activity> 
      </application> 
    </manifest> 

: 나는 다음과 같은 XML 문서를 가지고있다. 첫 번째 노드에 실수로 노드를 만들지 않고 어떻게합니까? <intent-filter>?

예상 출력 :이 상황에 대한 솔루션을 누락 된 것으로 나타납니다, http://xmlstar.sourceforge.net/doc/xmlstarlet.txt 그러나 :

<manifest> 
      <application> 
        <activity> 
          <intent-filter> 
            <action/> 
            <category/> 
          </intent-filter> 
          <intent-filter> 
            <action/> 
          </intent-filter> 
        </activity> 
      </application> 
    </manifest> 

난에서 문서를 검토했습니다.

감사합니다.

답변

0

사실, XPath 문제가 발생했습니다.

xml ed -s "(/manifest/application/activity/intent-filter)[2]" -t elem -n action -v "" manifest.xml 

이 작업을 수행 할 수있는 또 다른 표준 방법이 있다면 소리 내야합니다.