XML split attribute value on multiple line

大憨熊 提交于 2019-12-23 07:06:01

问题


I have XML data which contains a long attribute value. The value does not contain white space characters. I want to format the XML for readability by splitting the XML text so that the line does not exceed a maximum number of column.
Is there any mean to accomplish this? Is there any break character that I can put at each end of line so that the XML parser does not consider it as a white space (like underscore character in visual basic)?

For example:

<element attribute="this_is_a_very_long_text_attribute_value_that_I_want_to_split_on multiple_line_for_readability"/>

I want to have something like:

<element attribute="this_is_a_very_long
_text_attribute_value_that_I_want_to_split
_on multiple_line_for_readability"/>

回答1:


there is no provision in XML itself for line feed character in Attribute Values
however this can be done depending upon the IDE you are using this to write
ie. if you are using Visual Studio there is a provision to break lines and is handled by the IDE itself
but if you are using some low level text editor like Notepad this cant be done
you should probably check in the documentation of your XML editor




回答2:


Well there is a way: In short just use tab's instead of space. For more please look at this answer. https://stackoverflow.com/a/38880984/3135511

Hmm well IDE like the Chrome Developer Tool or Visual Studio may trap and limit you in doing so, but some ordinary editor will get this done and the html/xml will handle it.



来源:https://stackoverflow.com/questions/11393159/xml-split-attribute-value-on-multiple-line

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