Is it possible to split a string across multiple lines in an XML file? If so, how?

谁说我不能喝 提交于 2019-11-29 16:46:30

问题


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:

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


回答1:


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



来源:https://stackoverflow.com/questions/1184097/is-it-possible-to-split-a-string-across-multiple-lines-in-an-xml-file-if-so-ho

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!