bash 스크립트로 xml 파서를 저장할수있나요?

rhehfl2의 이미지

<dict>
	<key>curKey</key>
        <string>1</string>
	<key>hostList</key>
	<dict>
		<key>1</key>
		<dict>
			<key>xx</key>
			<string>xxxx</string>
			<key>xx</key>
			<string>xxxx</string>
			<key>xxxx</key>
			<string>xxxx</string>
			<key>xxxx</key>
			<string>xxxxx</string>
		</dict>
		<key>1_1</key>
		<dict>
			<key>xx</key>
			<string>xxxx</string>
			<key>xx</key>
			<string>xxxx</string>
			<key>xxxx</key>
			<string>xxxx</string>
			<key>xxxx</key>
			<string>xxxxx</string>
		</dict>
		<key>2</key>
		<dict>
			<key>xx</key>
			<string>xxxx</string>
			<key>xx</key>
			<string>xxxx</string>
			<key>xxxx</key>
			<string>xxxx</string>
			<key>xxxx</key>
			<string>xxxxx</string>
		</dict>
.........

현재 xml 문서입니다.

제가 가져와야 되는부분은 두번째 dict의 key값 (1, 1_1, 2)입니다.

이걸 가져오기 위해

cat serverList.plist |
getElementViaXPath --path='/dict/dict' |
sed -e 's%(^|$)%%g' > aa.txt

를 했는데, getElementViaXpath부분에서 에러가 발생하더군요...

이방법이 잘못된거 같은데 틀린 부분이나 혹은 다른 방법으로 해결할 수 있을까요?

rhehfl2의 이미지

<>안의 것들이 전부 날라갔네요..

최상위노드는 <dict

hostlist밑에 두번째노드 <dict 그리고 1이 두번째노드 안의 <key입니다.

김정균의 이미지

< code > 내용 < /code > 와 같이 하시면 코드들을 표현할수 있습니다.

chisquare88의 이미지