0
$ xidel --output-format html -s -e 'x:replace-nodes(//script,())' - <<< '<html><head><script>x=1</script><link href="http://example.com" type='text/css' rel='stylesheet' /></head><body>abc</body></html>'
<!DOCTYPE html>
<html><head><link href="http://example.com" type="text/css" rel="stylesheet"></head><body>abc
</body></html>

In the above example, <link href="http://example.com" type="text/css" rel="stylesheet" /> is contracted to <link href="http://example.com" type="text/css" rel="stylesheet">.

Shouldn't the last slash be maintained in the output?

user1424739
  • 11,937
  • 17
  • 63
  • 152
  • Do the answers of [7366344](https://stackoverflow.com/q/7366344) and/or [3558119](https://stackoverflow.com/q/3558119) answer your question? – Reino Aug 28 '22 at 12:05
  • But my input ends with `/>`, which obviously does not follow the HTML5 convention of just using '>'. I want the output follows the same convention as the input. How to do it? – user1424739 Aug 28 '22 at 14:25
  • Xidel's input is always parsed **and** altered/fixed by its HTML-parser, so I'm not sure you can. If you disagree, you can [file a report](https://github.com/benibela/xidel/issues). – Reino Aug 28 '22 at 15:11
  • You could use `--printed-node-format xml`. – BeniBela Sep 03 '22 at 09:58

0 Answers0