2
是否可以使用Simple XML將XML標記的內容作爲Java中的字符串獲取? 我正在嘗試使用Converter。我可以使用<tag1>
作爲InputNode對象,但是沒有API可以以String的形式檢索內容。我可以使用InputNode.getNext()
來迭代子節點,並通過遞歸地檢索名稱,屬性,值等重構內容......但我絕不會確定它會匹配原始XML。如何在SimpleXML(Java)中將InputNode作爲字符串獲取
例子:
<root>
<tag1>
<unknownTag>Unknown</unknownTag>
<otherUnknownTag>
<children1>hello</children1>
<children2>bye</children2>
</otherUnknownTag>
</tag1>
<tag2>
...
</tag2>
</root>
我想檢索<tag1>
以下內容作爲字符串(防止deserialisation所有<tag1>
兒童):
<unknownTag>Unknown</unknownTag>
<otherUnknownTag>
<children1>hello</children1>
<children2>bye</children2>
</otherUnknownTag>
的<tag1>
的內容尚不得而知在反序列化時間。