我有一个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文件中的多行中分割字符串?如果是这样,怎么办?
发布评论