這個問題可能已經在Interwebs的一些黑暗的休息之前得到了回答,但我甚至無法弄清楚如何形成有意義的Google查詢來搜索它。JAXB:獲取標記爲字符串
所以:假設我有一個像(簡體)XML文檔這樣:
<root>
<tag1>Value</tag1>
<tag2>Word</tag2>
<tag3>
<something1>Foo</something1>
<something2>Bar</something2>
<something3>Baz</something3>
</tag3>
</root>
我知道如何使用JAXB解組此爲Java對象的標準用例。
什麼我不知道該怎麼辦是取消編組tag3
的內容批發成一個字符串。我的意思是:
<something1>Foo</something1>
<something2>Bar</something2>
<something3>Baz</something3>
作爲一個字符串,標籤和所有。
在這種情況下,您不是在編組。獲取完整的XML並使用正則表達式或自定義分析來獲取'' –