4

I have the following code:

#!/bin/bash
task=$1
xml=$(curl -sL "http://login:[email protected]/issues/$task.xml")
id=$(xmllint --xpath '//issue/id/text()' --format - <<<"$xml")
name=$(xmllint --xpath '//issue/subject/text()' --encode utf8 - <<<"$xml")

echo "task #$id - $name"

But when I run it I get encoded cyrillic text like this:

task #10014 - &#x41B;&#x438;&#x447;&#x43D;&#x44B;&#x439; &#x43D;&#x43E;&#x43C;&#x435;&#x440; &#x43A;&#x43B;&#x438;&#x435;&#x43D;&#x442;&#x430;

Please help to fix it. I don't want this text encoded

1 Answer 1

4

After a few minutes of fighting with xmllint, I usually give up and end up using xmlstarlet instead which is usually more inclined to doing what you expect it to do. Here:

xmlstarlet sel -t -v '//issue/subject' <<< "$xml"

(or <rant>give up altogether on XML and use a more sensible format</rant>).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .