0

I want to verify the status become "ready" before performing the next action. However, the client return the status in HTML format. How can I just get the "ready" value?

Code

echo "$status"

Output:

<reply><contents><status>ready</status>
</contents>
<status>OK</status>
</reply>
0

1 Answer 1

3

Looks like you've got some valid XML there. You can get the ready part out like this:

xmllint --xpath '//contents/status/text()' file.xml

Tempting as it may be in this relatively simple case to use a regular expression to extract the part you're interested in, I would strongly recommend against it, as it is the wrong tool for the job and will break as soon as the input changes slightly. This approach is much more flexible.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.