Re: [問題] XML Document轉String
※ 引述《montreal (╮(╯3╰)╭)》之銘言:
: 請問各位
: 當用JDOM實現XML,產生Document類別後
: 如何將之轉為String,又如何轉回Document?
: (像是XOM的Document.toXML()傳回String功能)
: 謝謝
它文件上面不就有有寫
要用API之前要先看使用說明阿
在Document class的文件說明上toString()這樣寫
toString
public java.lang.String toString()This returns a String representation of the
Document, suitable for debugging. If the XML representation of the Document
is desired, XMLOutputter.outputString(Document) should be used.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
例如
XMLOutputter outtper = new XMLOutputter();
String xml = outter.outputString(document);
官方文件上有一章寫的
Reading XML Documents with JDOM
看完之後你應該就會知道怎麼做
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.105.36
討論串 (同標題文章)