2012-05-30 4 views
3

설명 필드가있는 객체가 있다고합시다. 이 필드는 일부 html 마크 업과 함께 String 값을 가질 수 있습니다. 이 Object가 마샬링 될 때 내 요소 내에서 HTML 마크 업을 이스케이프 처리하지 못하도록합니다.

"Say <b xmlns="http://www.w3.org/1999/xhtml">Hello</b> Wold" 

, 나는 다음과 같은 결과가있는 XML을 검색하는 대신

<description>Say &lt;b&gt;Hello&lt;/b&gt; World</description> 

나는

<description>Say <b xmlns="http://www.w3.org/1999/xhtml">Hello</b> World</description> 

방법이 있나요 이스케이프 유지하기 위해 HTML 마크 업을하고 싶습니다 예를 들어 내 분야의 주석을 사용하여이를 달성하려면?

marshaller.setProperty("com.sun.xml.bind.characterEscapeHandler", new CharacterEscapeHandler() { 
      @Override 
      public void escape(char[] ch, int start, int length, boolean isAttVal, 
           Writer out) throws IOException { 
       out.write(ch, start, length); 
      } 
     }); 
+1

도움말해야 다음 : http://blog.bdoughan.com/2011/04 여기 –

+1

가능한 [XML 요소의 내부 텍스트를 추출하기 위해 JAXB 사용하기] (http://stackoverflow.com/questions/5537416/using-jaxb-to-extract-inner- text-of-xml-element) –

답변

0

도움

에 대한

덕분에 HTML 특수 문자를 탈출하는 Marshaller를 방지하는 방법을 적절한 방법입니다 /xmlanyelement-and-non-dom-properties.html

관련 문제