【问题标题】:Passing input to xmllint as string not as file将输入作为字符串而不是文件传递给 xmllint
【发布时间】:2021-09-24 06:51:10
【问题描述】:

我需要从 python 脚本调用 xmllint 并将模式和输入作为字符串变量而不是文件传递。可能吗??如果是,格式是什么??

【问题讨论】:

    标签: python xmllint


    【解决方案1】:

    Xmllint 通过标准输入仅接受 2 个中的一个

    将命令传递给--shell 选项

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

    通过标准输入传递文档

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

    【讨论】:

      猜你喜欢
      • 2017-11-14
      • 1970-01-01
      • 2012-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-31
      • 2018-03-29
      • 1970-01-01
      相关资源
      最近更新 更多