Chaithra Devanur
Chaithra Devanur

Reputation: 21

Passing input to xmllint as string not as file

I need to call xmllint from python script and pass schema and input as string variables not as files. Is it possible?? If yes what is the format??

Upvotes: 2

Views: 808

Answers (2)

Donald Duck
Donald Duck

Reputation: 8882

The - option tells xmllint to read from stdin instead of a file (source). This can be combined with the pipe operator (|) to input a string directly:

echo '<xml hello="world"></xml>' | xmllint -

Upvotes: 0

LMC
LMC

Reputation: 12662

Xmllint accepts only one of the 2 via stdin

Passing commands to --shell option

(echo "cat //tag1"; echo "cd /root/tag2"; echo "cat") | xmllint --shell test.xml

Passing document via stdin

cat test.xml | xmllint --xpath '//tag1' -

Upvotes: 0

Related Questions