상세 컨텐츠

본문 제목

XML 에서 문자열에 \n 인식하기

프로그래밍 관련/프로그래밍 관련팁

by AlrepondTech 2019. 5. 7. 01:36

본문

반응형

 

 

 

 

=======================

=======================

=======================

 

 

 

 

 

 

 

출처: https://flystone.tistory.com/90

 

XML 에 문자를 넣으면 특수기호들 (예:줄바꿈 \n) 등이 그대로 출력되는 경우가 있다.

이 경우 XML 전용 문자들로 바꾸어 사용하면 된다.

 

\n  = 




출처: https://flystone.tistory.com/90 [MomO]

 

 

 

 

=======================

=======================

=======================

 

 

출처: http://blog.naver.com/PostView.nhn?blogId=adolkristin&logNo=220952232868&categoryNo=0&parentCategoryNo=0&viewDate=¤tPage=1&postListTopCurrentPage=1&from=postView

 

XML Spreadsheet Reference 이용하여 엑셀 파일로 저장하는데, 개행문자(\n 이나 <br/>)로 바꿔도 인식이 되지 않는다.
\n   대신  &#10; 로 바꾸면 된다.
단, 줄바꿈 허용을 미리 해놔야 함 (Style에서 지정)

XML Spreadsheet Reference

msdn.microsoft.com

Attribute:ss:WrapText
Description:Specifies whether the text in this cell should wrap at the cell boundary. False means that text either spills or gets truncated at the cell boundary (depending on whether the adjacent cell(s) have content). The Spreadsheet component does not support this attribute.
Type:Boolean
Default:0 (False)

<Style ss:ID="outLine"> <Alignment ss:WrapText="1"/> <Borders> <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/> <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/> <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/> <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/> <Border ss:Position="DiagonalLeft" ss:LineStyle="None" ss:Weight="1"/> <Border ss:Position="DiagonalRight" ss:LineStyle="None" ss:Weight="1"/> </Borders> </Style>



str_replace("&","&#10;", "바꿀 문자열");
preg_replace("|&|","&#10;", "바꿀 문자열");

<Cell ss:StyleID="outLine"><Data ss:Type="String"><

[출처] xml 사용 시 줄바꿈(개행) 문자|작성자 원더풀

 

 

 

반응형

 

728x90

 

 

 

 

=======================

=======================

=======================

 

 

 

출처: https://aker.tistory.com/259

 

 

&#아스키코드;

 

XML 파일을 스트링 테이블 등으로 사용하는 경우가 많이 있다. 이 때 개행을 위해 \n 등의 개행 문자를 넣고 싶을 경우가 많이 있는데, 문자열에 바로 \n을 넣으면 개행이 되지 않고 문자로 인식해 \n이 그냥 출력이 된다. 

 

따라서 특수 문자를 넣고 싶을 때는 위의 코드를 이용한다. 삽입을 원하는 부분에 복사한 후 "아스키코드"에 ASCII 코드 번호를 삽입하면 된다. 예를 들어 C++에서 개행으로 사용되는 \n은 ASCII 코드로 10인 LF(Line Feed)이므로 다음과 같다.

 

&#10; 

 

XML에서는 대략 다음과 같은 형태를 갖을 것이다.

 

<String Text="안녕하세요? &#10; 여기서 개행이 됩니다."/>



출처: https://aker.tistory.com/259 [A Gangster World]

 

 

 

 

=======================

=======================

=======================

 

 

 

반응형


관련글 더보기

댓글 영역