구문 분석하려는 Gmail 계정에서 일부 XML 데이터를 가져오고 있습니다. 를 Ths XML 데이터는 다음과 같습니다xmllint 및 xpath는 https://mail.google.com/mail/feed/atom에서 xml 데이터를 구문 분석합니다.
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://purl.org/atom/ns#" version="0.3">
<title>Gmail - Inbox for @gmail.com</title>
<tagline>New messages in your Gmail Inbox</tagline>
<fullcount>54</fullcount>
<link rel="alternate" href="http://mail.google.com/mail" type="text/html"/>
<modified>2014-11-25T04:40:04Z</modified>
<entry>
<title>test</title>
<summary/>
...
</feed>
내가 같은 모든 항목의 모든 타이틀을 얻기 위해 호핑했다 : 이제
xmllint --xpath '//feed/entry/title' myfile.xml
, 나는이 있다면이 일 것을 발견 이것은 xmlns 정보가 아닙니다. 는 그러나 XMLNS 정보와 함께, 내가 메시지를 얻을
의 XPath 세트는
I합니다 (XMLNS 부분을 제거) 파일을 수정하지 않고,이 파일을 구문 분석하는 간단한 oneliner 싶습니다 비어 있습니다.
-> 편집 : 에코 "setns X = http://purl.org/atom/ns# \ nxpath/X : 피드/X : 항목/X : 제목/텍스트()"
[xmllint가 xpath를 사용하여 제대로 쿼리하지 못했습니다] 중복 가능성이 있습니다. (http://stackoverflow.com/questions/8264134/xmllint-failing-to-properly-query-with-xpath) –