如何减少 XML 字符串长度以存储在数据库中?

How to reduce XML string length for storing in DB?

我有看起来像这样的 XLM(长度为 278 个字符):

<AppList>
  <App>
    <Info1>Value 1</Info1>
    <Info2>Value 2</Info2>
    <Info3>Value 3</Info3>
    <AppList>
      <App>
        <Info1>Value 4</Info1>
        <Info2>Value 5</Info2>
        <Info3>Value 6</Info3>
      </App>
    </AppList>
  </App>
</AppList>

为了存储在数据库中,我希望它看起来像这样(长度为 192 个字符):

<AppList><App><Info1>Value 1</Info1><Info2>Value 2</Info2><Info3>Value 3</Info3><AppList><App><Info1>Value 4</Info1><Info2>Value 5</Info2><Info3>Value 6</Info3></App></AppList></App></AppList>

在 Notepad++ 中,他们有类似 Linearize XML 的东西。
有什么方法可以在 C# 中以编程方式执行此操作吗?

可以考虑以下方法

  1. 参考the duplicated content,可以用C#实现。

  2. Just Compress text-to-text: 有几种压缩文本的方法。当然,之后很难进行字符串搜索。

  3. Use XML support in SQL: most of SQL database stores XML in compressed manner natively. Or this article 也有帮助。

  4. Describe in Json:XML 通常比 json 表达式冗长。 XML 和 json 都是树结构,所以 1:1 转换是可能的。