2017-01-10 80 views
-1

我有XLM,看起来像(长度278个字符):如何减少用于存储在数据库中的XML字符串长度?

<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> 

在记事本++他们有像Linearize XML这样做的工作。
有没有办法在C#中以编程方式做到这一点?

+2

的可能的复制[C#/ XSLT:线性化XML部分工作码(http://stackoverflow.com/questions/15131542/c-xslt-linearizing-xml-partially-working-code) –

+0

@MohitShrivastava建议的副本没有好的答案 – Toshi

+0

'Regex.Replace(xmlString,@“> \ s + <", "><”)''。可能有一些边缘案例可能会有问题。 –

回答

相关问题