是否可以在XML文件中的多行中分割字符串?如果是这样,怎么办?

编程入门 行业动态 更新时间:2024-10-28 11:31:15
本文介绍了是否可以在XML文件中的多行中分割字符串?如果是这样,怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个XML配置文件,其中包含一些非常长的字符串.通常,我会格式化源文件等,以便无需滚动即可读取它们.我想对这个配置文件做同样的事情.

I've got an XML config file with some really long strings. Generally, I format my source files, etc. so that they can be read without scrolling. I'd like to do the same to this config file.

是否可以将字符串拆分成多行?希望我的要求很明显,但是一张图片可以说一千个字,例如值,如下.

Is there a way to split the string across more than one line? Hopefully, what I'm asking for is obvious but a picture says a thousand words so, e.g. value, below.

<add name="validation" type="Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.ValidationElement, Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

如果我打破上面的字符串看起来像这样:

If I break the above string to look like this:

<add name="validation" type="Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.ValidationElement, Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

我的应用失败,并显示:

my apps fails with:

为system.serviceModel/behaviors创建配置节处理程序时发生错误:无法将扩展元素'validation'添加到该元素.请验证扩展名是否已在system.serviceModel/extensions/behaviorExtensions的扩展集合中注册. 参数名称:元素"

"An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element 'validation' cannot be added to this element. Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions. Parameter name: element "

似乎对字符串中的换行符很敏感.

It seems that it's sensitive to line-breaks in the string.

推荐答案

所有换行符都是标准化为空格,因此,如果空格分隔符可以处理任意空白,只需将它们放在单独的行上.

All line breaks are normalized to spaces, so just put them on a separate line if the space delimiter can handle arbitrary whitespace.

更多推荐

是否可以在XML文件中的多行中分割字符串?如果是这样,怎么办?

本文发布于:2023-07-30 11:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1248869.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是这样   字符串   文件   XML   多行中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!