{"id":356,"date":"2023-11-23T14:51:10","date_gmt":"2023-11-23T06:51:10","guid":{"rendered":"https:\/\/blog.quantoyo.com\/?p=356"},"modified":"2023-11-23T14:51:10","modified_gmt":"2023-11-23T06:51:10","slug":"linux-macos-xmllint-%e6%8c%87%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/blog.quantoyo.com\/?p=356","title":{"rendered":"Linux MacOS xmllint \u6307\u4ee4"},"content":{"rendered":"\n<p>\u4f7f\u7528xmllint \u6307\u4ee4\u683c\u5f0f\u5316 xml \u6a94\u6848<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u5982\u679c\u9047\u5230\u683c\u5f0f\u8dd1\u6389\u7684xml file\uff0c\u5982\u4f55\u5c07\u5176\u683c\u5f0f\u8b8a\u6f02\u4eae<\/p>\n\n\n\n<p>\u73fe\u5728\u6709\u4e00\u500btest.xml\u6a94\u6848\u5167\u5bb9\u70ba<\/p>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background has-small-font-size\"><code>\n&lt;Layer1>&lt;Layer2>&lt;Param1>123&lt;\/Param1>&lt;Param2>234&lt;\/Param2>&lt;\/Layer2>&lt;Layer2>&lt;Param1>345&lt;\/Param1>&lt;Param2>456&lt;\/Param2>&lt;\/Layer2>&lt;Param3>Quanto&lt;\/Param3>&lt;\/Layer1>\n\n<\/code><\/pre>\n\n\n\n<p>\u53ea\u9700\u8981\u4f7f\u7528xmllint -format test.xml \u6307\u4ee4\u5373\u53ef\u7372\u5f97\u683c\u5f0f\u5316\u5f8c\u7684\u6a23\u5b50<\/p>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background has-small-font-size\"><code>xmllint -format test.xml\n\n&lt;?xml version=\"1.0\"?>\n&lt;Layer1>\n&lt;Layer2>\n&lt;Param1>123&lt;\/Param1>\n&lt;Param2>234&lt;\/Param2>\n&lt;\/Layer2>\n&lt;Layer2>\n&lt;Param1>345&lt;\/Param1>\n&lt;Param2>456&lt;\/Param2>\n&lt;\/Layer2>\n&lt;Param3>Quanto&lt;\/Param3>\n&lt;\/Layer1><\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u4f7f\u7528\u201c&gt;\u201d \u5c07\u8f38\u51fa\u7684\u5167\u5bb9\u53e6\u5916\u5b58\u653e\u5728\u65b0\u7684\u6a94\u6848\u5167<\/p>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background has-small-font-size\"><code>xmllint -format test.xml > test2.xml<\/code><\/pre>\n\n\n\n<p>\u6a94\u6848\u5167\u5bb9\u770b\u8d77\u4f86\u5c31\u50cf\u9019\u6a23<\/p>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background has-small-font-size\"><code>vi test2.xml\n\n&lt;?xml version=\"1.0\"?>\n&lt;Layer1>\n&lt;Layer2>\n&lt;Param1>123&lt;\/Param1>\n&lt;Param2>234&lt;\/Param2>\n&lt;\/Layer2>\n&lt;Layer2>\n&lt;Param1>345&lt;\/Param1>\n&lt;Param2>456&lt;\/Param2>\n&lt;\/Layer2>\n&lt;Param3>Quanto&lt;\/Param3>\n&lt;\/Layer1><\/code><\/pre>\n\n\n\n<p>\u53e6\u5916\uff0c\u6b64\u64cd\u4f5c\u53ef\u4ee5\u53cd\u904e\u4f86\uff0c\u5c07\u6f02\u4eae\u7684xml \u8b8a\u6210\u4e00\u884c<\/p>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background has-small-font-size\"><code>xmllint --noblanks test2.xml\n\u5c07\u6703\u5f97\u5230\n&lt;?xml version=\"1.0\"?>\n&lt;Layer1>&lt;Layer2>&lt;Param1>123&lt;\/Param1>&lt;Param2>234&lt;\/Param2>&lt;\/Layer2>&lt;Layer2>&lt;Param1>345&lt;\/Param1>&lt;Param2>456&lt;\/Param2>&lt;\/Layer2>&lt;Param3>Quanto&lt;\/Param3>&lt;\/Layer1><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528xmllint \u6307\u4ee4\u683c\u5f0f\u5316 xml \u6a94\u6848<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[55,37,30,54,52,53],"class_list":["post-356","post","type-post","status-publish","format-standard","hentry","category-technology","tag-format","tag-linux","tag-macos","tag-noblanks","tag-xml","tag-xmllint"],"_links":{"self":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=356"}],"version-history":[{"count":1,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/356\/revisions"}],"predecessor-version":[{"id":357,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/356\/revisions\/357"}],"wp:attachment":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}