Skip to content

Instantly share code, notes, and snippets.

@ibaaj
Last active September 21, 2017 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibaaj/4dfa41a8c173d13a98f2ea6dce1b3687 to your computer and use it in GitHub Desktop.
Save ibaaj/4dfa41a8c173d13a98f2ea6dce1b3687 to your computer and use it in GitHub Desktop.
#!/bin/zsh
read -d '' query << EOF
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns="http://wsiv.ratp.fr" xmlns:xsd="http://wsiv.ratp.fr/xsd">
<soap:Header/>
<soap:Body>
<getMissionsNext>
<station>
<xsd:id>181</xsd:id>
<xsd:line>
<xsd:id>M7</xsd:id>
</xsd:line>
</station>
<direction>
<xsd:sens>A</xsd:sens>
</direction>
</getMissionsNext>
</soap:Body>
</soap:Envelope>
EOF
xmlArgsParsingParts=(
'//*[local-name()="Envelope"]/*[local-name()="Body"]'
'/*[local-name()="getMissionsNextResponse"]'
'/*[local-name()="return"]'
'/*[local-name()="missions"]/*[local-name()="stationsMessages"]'
)
xmlArgsParsing=$(IFS=; echo "${xmlArgsParsingParts[*]}")
A=$(curl --silent -X POST \
-H 'Content-Type: application/soap+xml;charset=UTF-8' \
-d $query \
'http://opendata-tr.ratp.fr/wsiv/services/Wsiv?wsdl=' | \
xmllint --xpath $xmlArgsParsing - | \
sed -e "s/<\//,<\\//g" | \
sed 's/<[^>]*>//g' | \
sed 's/.$//');
echo $A;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment