I am trying to parse the XML Google contact file using tools like xmllint and I even dived into the XSL Style Sheets using xsltproc but I get nowhere.
I can not supply any sample file as it contains private data but you can download your own contacts using this script:
I can get the root node:
But it fails when I try the first node below root: <feed>
I can not supply any sample file as it contains private data but you can download your own contacts using this script:
Code:
#!/bin/sh
# imports Google Contacts
# imported data is stored in contacts.xml file (current directory)
# You will need curl and xmllint tools
LOGIN="your.login@gmail.com"
PASSW="your_passw"
AUTH=$(curl --silent https://www.google.com/accounts/ClientLogin \
-d Email=$LOGIN \
-d Passwd=$PASSW \
-d accountType=GOOGLE \
-d service=cp \
-d Gdata-version=3.0 | grep '^Auth')
curl --silent -o /tmp/contacts.tmp https://www.google.com/m8/feeds/contacts/default/full?max-results=5 \
--header "Authorization: GoogleLogin auth=${AUTH#*=}" \
--header "GData-Version: 3.0" \
# format nicely the Google output
xmllint --format /tmp/contacts.tmp > contacts.xml
Code:
$ xmllint --xpath '/' contacts.xml
Code:
$ xmllint --xpath '/feed' contacts.xml
XPath set is empty