【问题标题】:Save XML response to file with formatting将 XML 响应保存到带有格式的文件
【发布时间】:2015-07-29 19:34:13
【问题描述】:

我正在向 Web 服务发出 SOAP 请求,并且正在接收 XML 响应。目前我正在将此 XML 保存到一个可以正常工作的文件中,但是 XML 看起来很乱,没有换行符和缩进。 一行见这个例子:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><SoegPersonRegistreringCprResponse xmlns="http://webservices.rki.dk/"><SoegPersonRegistreringCprResult><Error xmlns="http://webservices.rki.dk"><Code>101</Code><Text>Generel fejl</Text><Detailed>InternWS.Common.Exceptions.InternWSException: Generel fejl</Detailed></Error></SoegPersonRegistreringCprResult></SoegPersonRegistreringCprResponse></soap:Body></soap:Envelope>

在编辑器中看起来像这样:

是否可以将此 XML 保存到文件中并像在浏览器中一样保持良好的格式。看这个例子:

【问题讨论】:

    标签: xml soap pretty-print


    【解决方案1】:

    如果您使用的是 Notepad++,您可以使用 XML Tools 插件来美化您的 XML 文件。

    请注意,没有缩进和换行符的原始文件仍然是有效 XML,尽管它的可读性较差。

    【讨论】:

      猜你喜欢
      • 2014-03-29
      • 1970-01-01
      • 1970-01-01
      • 2015-06-01
      • 2011-10-10
      • 1970-01-01
      • 1970-01-01
      • 2021-09-08
      • 2015-09-16
      相关资源
      最近更新 更多